Guest aXiS_PoWeR Posted November 12, 2002 Posted November 12, 2002 how do you control objects on one form from another? in VB6 it was as simple as formname.textbox.text="blah"...now since they took out the simple things in life i cant figure out a way to do that...can anyone tell me how? Quote
mpappert Posted November 12, 2002 Posted November 12, 2002 I'll assume you are calling one form (frmPopup) from your main form (frmMain). You should be calling this form as follows: Dim Popup As New frmPopup() Popup.Show() You can then reference obects on that form. For example, say you have an label called "lblChangeMe" then you can change the text property with code as follows: Popup.lblChangeMe.Text = "This text was changed by frmMain" Hope this helps! M. Quote
*Gurus* divil Posted November 12, 2002 *Gurus* Posted November 12, 2002 I suspect he's trying to access stuff on frmMain from frmPopup. If he'd have searched this forum he'd have found this question is asked in various forms at least once a week. My preferred solution is to alter the constructor of the secondary form so it takes a reference to the first form as a parameter, which can be stored for whenever you need to access it. You could also set the tag of the secondary form to reference the first form after creating it, but that would mean you wouldn't be able to reference frmMain from the constructor. 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
*Gurus* Derek Stone Posted November 13, 2002 *Gurus* Posted November 13, 2002 http://www.visualbasicforum.com/showthread.php?s=&threadid=45326 Quote Posting Guidelines
Guest aXiS_PoWeR Posted November 13, 2002 Posted November 13, 2002 i did the constructor n everything but still from form2 i can only get properties of form1 and not the controls on it... Quote
*Gurus* divil Posted November 13, 2002 *Gurus* Posted November 13, 2002 Then you're declaring it wrong. Declare it as frmMain, not Form. Or cast it when necessary. 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
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.