statusbar UI
-
just wondering what methods do i need to override to be able to change bankground color of the status bar? set for exemple a gradient fill backgroung like with iexplorer/explorer. so far i got just been able to have the devider but no bg :(
private void statusbarDrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent) { StatusBarPanel ssb = sbdevent.Panel; Rectangle rect = sbdevent.Bounds; sbdevent.Graphics.DrawLine(new Pen(Color.White), rect.Right-1,rect.Top,rect.Right-1,rect.Bottom-2); sbdevent.Graphics.DrawLine(SystemPens.ControlDark, rect.Right-2,rect.Top,rect.Right-2,rect.Bottom-2);}
-
just wondering what methods do i need to override to be able to change bankground color of the status bar? set for exemple a gradient fill backgroung like with iexplorer/explorer. so far i got just been able to have the devider but no bg :(
private void statusbarDrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent) { StatusBarPanel ssb = sbdevent.Panel; Rectangle rect = sbdevent.Bounds; sbdevent.Graphics.DrawLine(new Pen(Color.White), rect.Right-1,rect.Top,rect.Right-1,rect.Bottom-2); sbdevent.Graphics.DrawLine(SystemPens.ControlDark, rect.Right-2,rect.Top,rect.Right-2,rect.Bottom-2);}
You want to use
Graphics.FillRectangle
with aLinearGradientBrush
:private void statusBarDrawItem(object sender,
StatusBarDrawItemEventArgs e)
{
// Should consider caching this brush for better performance.
LinearGradientBrush gradient = new LinearGradientBrush(
e.Bounds, Color.Blue, e.BackColor, LinearGradientMode.Horizontal);
e.Graphics.FillRectangle(gradient, e.Bounds);
// Draw lines and strings after the background, of course.
}Microsoft MVP, Visual C# My Articles