How Can I Create the Label Control with icon and button?

michaeln

New member
Joined
Aug 2, 2006
Messages
3
Programming Experience
3-5
How Can I Create the Label Control with icon and button ?

For example i need to display the message with warning icon and button (x) that closes the message.

Thanks.
 
You are describing the looks of a MessageBox or isn't that what you want exactly?

VB.NET:
MessageBox.Show("the message", "the title", MessageBoxButtons.OK, MessageBoxIcon.Warning)

grtz CygNuS
 
You are describing the looks of a MessageBox or isn't that what you want exactly?

VB.NET:
MessageBox.Show("the message", "the title", MessageBoxButtons.OK, MessageBoxIcon.Warning)

grtz CygNuS

Thanks, but I realy need the Label control, like warning label that will be displayed in the some place in application.
 
Add a User Control to your project. Name it ucMyLabel.vb or something

Now put a label and a button and an icon on that user control. Give it the functionalities you want.

Rebuild your project. Open the form you want your special label in.

Now when the label is needed, use this code:

VB.NET:
Dim uc As New ucmyLabel
Me.Controls.Add(uc)
uc.Label1.Text = "Appropriate warning Message for this form"

You can also set the position of that label via code.

Hope this is what you meant :)

Grtz CygNuS
 
Last edited:
You can create a usercontrol if label+picturebox is something you use often and you want a this as a single standard composite control, but commonly you just add these two regular controls label and picturebox to the forms. So there is usually no need to draw both icon and text to the label control.
 
Back
Top