Solved

Statusbar panels

Posted on 2004-10-07
10
273 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

13 Experts available now in Live!

Get 1:1 Help Now