More code questions

fantasma62

Member
Joined
Nov 23, 2002
Messages
18
Location
Miami, Florida
What type of code should I use if I have to print information in a panel on a status bar? There is text on it, however. The fact remains that along with the information contained in the labels. I also need to print the information that appears in my labels...
Thanks...
 
Im not exactly sure what you were saying.. maybe Im just tired. If you could explain better it would be appreciated.

Regardless of that heres a few snippets of code that may help you (assuming I understood what you said even partially).

Code:
Get each label inside the panel and print its text.
Dim c As Control
For Each c In Panel1.Controls
    If TypeOf c Is Label Then
        Console.WriteLine(c.Text)
    End If
Next

Print the text inside a panel.
Console.WriteLine(Panel1.Text)

Change the StatusBars text.
StatusBar1.Text = "Some text."
 
Sorry, Ill rephrase....
I created a status bar in a MdiParent form. This form is linked to a MDIChild form.
When you open the MdiParent form, 5 child forms open along with it. These child forms have 2 buttons and 2 labels. Anytime I press a button, a number appears in the label....
What I am trying to do is to have that number appear in one of the status bar panels.
The problem that I am having is that there already is text on the panel. Ill attach the solution so that you can have a look see. I hope that may help......
I apologize for my not being to explain it well. I am pretty new at this and dont yet know the lingo....
 

Attachments

Well, you can either create another statusbar panel and have the text displayed in that panel, or you can just do a simple:

sbrMenu.Panels(0).Text = "Customers Processed: " + someNum.ToString

Is that what you are getting at, how do you set text in a statusbar panel?
 
You have to specify the form the statusbar is on..

frmParent.sbrMenu.Panels(0).Text = "Customers Processed: " + someNum.ToString

frmParent = the name of your parent form.
 
I am sorry, nothing happened.
This is what I wrote:

Private iNumber1 As Integer
Dim frmParent as New frmMdiParent

Then, in the button click event I wrote the following:

iNumber1 += 1
lblInline.Text = iNumber1.ToString()
frmParent.sbrMenu.Panels(1).Text = "Customers in line " + iNumber1.ToString

Nothing happens there., it doesnt print in the panel

By the way, VB asked me to declare frmParent as New frmMdiParent

Sorry if I seem like a dummy. This is the first time for me studying VB
 
*scratch*

Im a little baffled as well. Ive tried several different ways that should work but they just arent (including making and calling a public function inside mdiParent to set the statusbar). There might be something with MDI forms that Im not aware of. Im sure its something simple, but unfortunately I havent played with .NET controls and forms enough to know what it is. :(
 
You need a reference to the main form to be able to change stuff on it. Since youre trying to change it from an mdi child, this is made slightly simpler. Heres the code:

Code:
DirectCast(Me.MDIParent, frmParent).sbrMenu.Panels(1).Text = "blah"
 
The problem here is that sometimes when you attempt to access the MDI parents status bar from the child form, that the form does not yet have its MDIParent property set. For example you instantiate a child form as follows:

dim frm as new frmSomething
frm.MDIParent = me

The first line fires the constructor which also fires the load event so anything in those that expects to be able to set the statusbar will not know the MDIParent. That is defined on the next line of code.

the simple answer is to add a reference to the parent form in the constructor.
i.e dim frm as new frmSomething(me) and use the overloaded constructor to set a private class member. That way the parent is known about from the word go.
 
Back
Top