I show winform as a dialog (with ShowDialog above the main window). Thus, I set FormBorderStyle to None, because I do not need either control boxes or a title bar. Although, I would like the drawn border (for example, a blue border, like ordinary windows), and retained the ability to move the form. I do not need the ability to resize it. I tried to draw a border by overriding OnPaint, but it is never called. Here is my code:
protected override void OnPaint (PaintEventArgs e) { base.OnPaint (e); int borderWidth = 2; Color borderColor = Color.Blue; ControlPaint.DrawBorder (e.Graphics, e.ClipRectangle, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid); }
Any help would be greatly appreciated.
c # winforms border move
Pierre Oct 25 '10 at 9:20 2010-10-25 09:20
source share