Custom Control -StatusBar.

G

garfitz

I am trying to create a custom control for a statusbar (set to red for erros etc..)

My test project has a blank form and a ColorStatusBar class.
Nothing is having an effect on the color of the statusbar!
Where am I going wrong ?

The ColorStatusBar class has the following code;

Public Class StatusBarRed
Inherits StatusBar
Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)

Me.BackColor = Color.Blue
Me.ForeColor = Color.Red
MyBase.OnPaint(pe)

End Sub
End Class

My blank form has the following code after the initialize component section.

'Add any initialization after the InitializeComponent() call
Dim StatusBar1 As New ColourStatusBar.StatusBarRed
StatusBar1.Location = New System.Drawing.Point(0, 248)
StatusBar1.Size = New System.Drawing.Size(240, 22)
StatusBar1.Text = "StatusBar1"
Me.Controls.Add(StatusBar1)
 
M

Maarten Struys

Isn't it true that StatusBar does not expose the OnPaint event and that a
ColorStatusBar should be derived from Control?

--
Regards,

Maarten Struys
PTS Software bv
 
A

Alex Yakhnin [eMVP]

You're right. Sorry, I missed that. He'd need to derive
his control from Control...

-Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top