Domanda

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

È stato utile?

Soluzione

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();
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top