Solved

Statusbar panels

Posted on 2004-10-07
10
281 Views
Last Modified: 2010-04-23
I'm using vb.net 2002 and I was wondering if there is a way to show and use other controls inside of a statusbar.  For example StatusBarPanel1 would contain some text and a NumericUpDown1 and StatusBarPanel2 would contain Button1 and both the controls could be used as if they were part of the form and not part of the statusbar. If it could be done can someone give a good commented code example of how to do it?
0
Comment
Question by:teamdad
  • 6
  • 3
10 Comments
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12255176
   Private Sub ShowButton()
        Dim nud As New NumericUpDown()
        With nud
            .Minimum = 0
            .Maximum = 15
            .Name = "nud"
            .ThousandsSeparator = True
        End With
        Me.StatusBar1.Controls.Add(nud)
    End Sub
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12255203
I have tried with this numericUpDown object and with a button
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12255245
Before adding the second and following controls you must calculate the x coordinate of the control you want to place:

Private Sub ShowButton()
    Dim i, x As Integer
    For i = 0 To Me.StatusBar1.Controls.Count - 1
        x += Me.StatusBar1.Controls(i).Width
    Next
    Dim nud As New NumericUpDown()
    With nud
        .Left = x
        .Minimum = 0
        .Maximum = 15
    End With
    Me.StatusBar1.Controls.Add(nud)
End Sub
0
 

Author Comment

by:teamdad
ID: 12255267
So, I use both pieces of code together?  they both have Private Sub ShowButton() and they can't have the same instance.
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12255298
No, the second code is the correct, because the previous was putting all the controls the others back of the first control.

The second code make the things better.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:teamdad
ID: 12255443
With a blank StatusBar1 on a form and using your code it doesn't add anything to the StatusBar. There isn't any errors just nothing on the statusbar.
0
 

Author Comment

by:teamdad
ID: 12255576
I added your code to my form load and it works without it being in it's own sub.  Is there any way I can add text either before or after the code?
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12256615
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12259030
When you create the textBox, comboBox, button or any other object to your statusBar you can set its text.

If you have added buttons you can add handlers to give them functionality:

dim btn as new Button()
with btn
  'The code to make this button unique
end with
addhandler btn.Click, addressof(me.btn_Click)

private sub btn_Click(sender as object, e as eventArgs)
  'Here you put the code to handle the click event for the button.
end sub
0
 
LVL 4

Accepted Solution

by:
eozz_2000 earned 500 total points
ID: 12259048
I don't know why you say that the code I send on 10/07/2004 07:51PM CDT doesn't works, I have proved it right now and it is so well.

I hope this could help you :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now