468,161 Members | 1,993 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,161 developers. It's quick & easy.

StatusBar.BackColor = Color.Yellow fails

OK, the direct method of setting the background color on a text-only (no
panels) statusbar control seems to fail:

Me.StatusBar1.Text = "<whatever> failed.>
Me.StatusBar1.Backcolor = Color.Yellow ' nothing changes
Me.StatusBar1.Refresh ' doesn't help either.

What convoluted work-around (must be if the simple, direct method fails) is
there for this?
Nov 20 '05 #1
3 2576
* "Fred Morrison" <fm*******@erols.com> scripsit:
OK, the direct method of setting the background color on a text-only (no
panels) statusbar control seems to fail:

Me.StatusBar1.Text = "<whatever> failed.>
Me.StatusBar1.Backcolor = Color.Yellow ' nothing changes
Me.StatusBar1.Refresh ' doesn't help either.


This property is not implemented for the StatusBar control. You may
want to define an ownerdrawn panel and draw its background by handling
the panel's 'DrawItem' event.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
I found this online somewhere, hope this helps

Public Class ColoredStatusBar

Inherits StatusBar

Private m_BackColor As Color = Color.Blue

Public Sub New()

MyBase.New()

Me.SetStyle(ControlStyles.UserPaint, True)

Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)

End Sub

Public Shadows Property BackColor() As Color

Get

Return m_BackColor

End Get

Set(ByVal Value As Color)

m_BackColor = Value

Me.Invalidate()

End Set

End Property

Protected Overrides Sub OnPaint( _

ByVal e As System.Windows.Forms.PaintEventArgs)

e.Graphics.FillRectangle(New SolidBrush(Me.BackColor), _

e.ClipRectangle)

e.Graphics.DrawString(Me.Text, Me.Font, New SolidBrush(Me.ForeColor), _

e.ClipRectangle.X, e.ClipRectangle.Y)

If Me.SizingGrip = True Then

ControlPaint.DrawSizeGrip(e.Graphics, Me.BackColor, e.ClipRectangle)

End If

End Sub

End Class

"Fred Morrison" <fm*******@erols.com> wrote in message
news:en*************@TK2MSFTNGP11.phx.gbl...
OK, the direct method of setting the background color on a text-only (no
panels) statusbar control seems to fail:

Me.StatusBar1.Text = "<whatever> failed.>
Me.StatusBar1.Backcolor = Color.Yellow ' nothing changes
Me.StatusBar1.Refresh ' doesn't help either.

What convoluted work-around (must be if the simple, direct method fails) is there for this?

Nov 20 '05 #3
http://www.dotnet247.com/247reference/msgs/9/45667.aspx

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Ox**************@tk2msftngp13.phx.gbl...
* "Fred Morrison" <fm*******@erols.com> scripsit:
OK, the direct method of setting the background color on a text-only (no
panels) statusbar control seems to fail:

Me.StatusBar1.Text = "<whatever> failed.>
Me.StatusBar1.Backcolor = Color.Yellow ' nothing changes
Me.StatusBar1.Refresh ' doesn't help either.


This property is not implemented for the StatusBar control. You may
want to define an ownerdrawn panel and draw its background by handling
the panel's 'DrawItem' event.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Dave | last post: by
1 post views Thread by Matt | last post: by
reply views Thread by Tom | last post: by
3 posts views Thread by tshad | last post: by
1 post views Thread by Matt | last post: by
4 posts views Thread by Rob | last post: by
6 posts views Thread by Dmitry Duginov | last post: by
1 post views Thread by gcdp | last post: by
reply views Thread by kamranasdasdas | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.