Category / Section
How to draw border around any control in Windows Forms?
1 min read
You can draw border over any Winforms controls, by using ControlPaint class and its DrawBorder function. For example, consider drawing border around ComboBoxAdv, by handling its Paint event. The following code example is to demonstrate the same.
C#
void myControl1_Paint(object sender, PaintEventArgs e) { ControlPaint.DrawBorder(e.Graphics, this.myControl1.ClientRectangle, Color.Black, ButtonBorderStyle.Solid); }
VB
Private Sub myControl1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) ControlPaint.DrawBorder(e.Graphics, Me.myControl1.ClientRectangle, Color.Black, ButtonBorderStyle.Solid) End Sub
The following screenshot illustrates the output.
Figure 1: Border around ComboBox
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ComboBoxBorder-1661082037.zip