views:

20

answers:

2

I use the following code to create a Label in the status strip when a child window is open.

Public Sub StatusStripPanelAdd(ByVal lCount As Integer, ByVal sImage As System.Drawing.Image, ByRef sText As String, ByVal sender As Object, ByVal e As System.EventArgs)

    With (StatusStrip2)

        .Items.Add(sText, sImage)

    End With

    Dim MyOwner As System.Windows.Forms.ToolStrip = StatusStrip2.Items.Item(lCount).Owner

    Dim MyValue As System.Windows.Forms.ToolStripItem = StatusStrip2.Items(lCount)

    Dim AccLabel As Object = MyValue

    Dim MyStripLabel As ToolStripStatusLabel = AccLabel

    MyStripLabel.BorderStyle = Border3DStyle.RaisedOuter

    MyStripLabel.LinkBehavior = LinkBehavior.HoverUnderline

End Sub

My problem is that label is not raised outer or the behavior of the label is not HoverUnderLine. Is there anybody to know how i can make the status label to beraisedouter or to be HoverUnderLine? I write my code in vb.net.

A: 

Here is what you want:


ToolStripStatusLabel myLabel = ((ToolStripStatusLabel)statusStrip1.Items[statusStrip1.Items.Count - 1]);
myLabel.LinkBehavior = LinkBehavior.HoverUnderline;
myLabel.BorderStyle = Border3DStyle.RaisedOuter;
Dr TJ
The Line in VB comes like that Dim myLabel As ToolStripStatusLabel = ((ToolStripStatusLabel)statusStrip2.Items[StatusStrip2.Items.Count - 1]).Please cross check it if i have any error on that. Even so the instruction don't work on VB, and also i haven't see parameters closed in brackets, is that suitable? thank you very much for the assistance
Lefteris Gkinis
+2  A: 

You will need to set some additional properties to enable the border and the link behavior. This worked well:

    Dim item = New ToolStripStatusLabel(sText, sImage)
    item.BorderSides = ToolStripStatusLabelBorderSides.All
    item.BorderStyle = Border3DStyle.RaisedOuter
    item.LinkBehavior = LinkBehavior.HoverUnderline
    item.IsLink = True
    StatusStrip1.Items.Add(item)
Hans Passant
Your assistance was much grate, can you tell me how i will change the fonts family and the fonts size?
Lefteris Gkinis
@Left - that's another question, please start a new one.
Hans Passant
You are grate i want to thank you very much for all of you assistance
Lefteris Gkinis