fantasma62 Posted November 25, 2002 Posted November 25, 2002 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... Quote
wyrd Posted November 25, 2002 Posted November 25, 2002 I'm not exactly sure what you were saying.. maybe I'm just tired. If you could explain better it would be appreciated. Regardless of that here's a few snippets of code that may help you (assuming I understood what you said even partially). 'Get each label inside the panel and print it's 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 StatusBar's text. StatusBar1.Text = "Some text." Quote Gamer extraordinaire. Programmer wannabe.
fantasma62 Posted November 25, 2002 Author Posted November 25, 2002 Sorry, I'll 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. I'll 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 don't yet know the lingo....ch11ex5.zip Quote
wyrd Posted November 25, 2002 Posted November 25, 2002 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? Quote Gamer extraordinaire. Programmer wannabe.
fantasma62 Posted November 25, 2002 Author Posted November 25, 2002 Thank you That's exactly it.... Thanks.... Quote
fantasma62 Posted November 25, 2002 Author Posted November 25, 2002 There is one thing, though, I am trying to set text from the Child to the Parent Status bar and I can't get them two to click together.... Quote
wyrd Posted November 25, 2002 Posted November 25, 2002 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. Quote Gamer extraordinaire. Programmer wannabe.
fantasma62 Posted November 25, 2002 Author Posted November 25, 2002 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 doesn't 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 Quote
wyrd Posted November 25, 2002 Posted November 25, 2002 *scratch* I'm a little baffled as well. I've tried several different ways that should work but they just aren't (including making and calling a public function inside mdiParent to set the statusbar). There might be something with MDI forms that I'm not aware of. I'm sure it's something simple, but unfortunately I haven't played with .NET controls and forms enough to know what it is. :( Quote Gamer extraordinaire. Programmer wannabe.
*Gurus* divil Posted November 25, 2002 *Gurus* Posted November 25, 2002 You need a reference to the main form to be able to change stuff on it. Since you're trying to change it from an mdi child, this is made slightly simpler. Here's the code: DirectCast(Me.MDIParent, frmParent).sbrMenu.Panels(1).Text = "blah" Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
fantasma62 Posted November 25, 2002 Author Posted November 25, 2002 Thank you all very much for your help....All of it has been invaluable to me....The problem has been resolved... Thank you so much.... Quote
wullemsp Posted July 10, 2003 Posted July 10, 2003 The problem here is that sometimes when you attempt to access the MDI parent's 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.