Sometimes we need to change the border color of a control to match its color with UI. Visual studio designer only allows us to choose borderStyle. To change border color of controls (like panel, DataGrid etc.) we need to write custom code to set the border color of control. Here is the custom code -
Use above paint function in the paint event for the control which requires custom border color.
private void ControlBorder_Paint(object sender, PaintEventArgs e)
{
try
{
Control ctrl = sender as Control;
ControlPaint.DrawBorder(e.Graphics, ctrl.ClientRectangle, Color.FromArgb(130, 135,144), ButtonBorderStyle.Solid);
}
catch (Exception ex)
{
//write log
}
}
Use above paint function in the paint event for the control which requires custom border color.
Comments
Post a Comment