سؤال

On a winform, is there a way to draw a rectangle like this (without top) using the DrawRectangle method or a workaround?

Rectangle without top

هل كانت مفيدة؟

المحلول

You can try using the SetClip method:

private void DrawTopless(Graphics g, Rectangle r) {
  g.SetClip(new Rectangle(r.Left, r.Top, r.Width + 1, 10), CombineMode.Exclude);
  g.DrawRectangle(Pens.Red, r);
  g.ResetClip();
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top