I set the Listbox's BorderStyle = BorderStyle.None, but I want to draw a simple border line around.
Code:
public partial class DropDownListBox : ListBox
{
public DropDownListBox()
{
//SetStyle(ControlStyles.UserPaint, true);
BorderStyle = BorderStyle.None;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
if (BorderStyle == BorderStyle.None)
{
e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, 0, 0, base.Width - 1, base.Height - 1);
}
}
}
SetStyle(ControlStyles.UserPaint, true) will cause all items aren't drawn.