using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
class MyPanel : Panel
{
private Color colorBorder = Color.Transparent;
public MyPanel() : base()
{
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawRectangle(
new Pen(
new SolidBrush(colorBorder), 2), e.ClipRectangle);
}
public Color BorderColor
{
get { return colorBorder; }
set { colorBorder = value; }
}
}
You can then use the new BorderColor property to set the border to any color you like.
Friday, June 28, 2019
WinForms: How To Add a Border To a Panel Control
To add a border to a Panel control, extend the control with the following class:
Subscribe to:
Post Comments (Atom)
Performance: Linking a List of Child Objects To a List of Parent Objects
Many a time I've had to build a relationship where a parent object has a list of child objects linked to it, where the parent itself als...
-
Visual Studio, by default, will include whitespace in its comparison when comparing two files. This is a workaround that seems to get arou...
-
WPF doesn’t have a built-in property to hide the title bar’s Min, Max and Close buttons, however, you can do it with a few lines of P/Invoke...
No comments:
Post a Comment