ICE Posted December 15, 2003 Posted December 15, 2003 Hi How do i show new forms that i've created? For example, in visual basic 6 it was "form1.show". I know you can do: dim frm1 as new form() frm1.show But i want to load a form that i created (ie from GUI). Hope you understand me. Also, while im at it, how do u make a control array in vb .net? So much has changed since vb6, i think i'll purchase a book or something. :D Thanks in advance :) Quote
AlexCode Posted December 15, 2003 Posted December 15, 2003 (edited) I belive that you're talking about showing forms that you've created in run-time ... is that it? If so: Every single control (From included) have a group of "basic" properties that must be assigned so that control can be displayed. On this case, you'll have to do this: Dim Form1 as System.Windows.Forms.Form Form1 = new System.Windows.Forms.Form With Form1 .AutoScaleBaseSize = New System.Drawing.Size(5, 13) .ClientSize = New System.Drawing.Size(292, 273) .Name = "Form1" .Text = "Form1" End With 'And finally show the form... Fom1.show Anything else... just ask... Alex :D Edited December 15, 2003 by AlexCode Quote Software bugs are impossible to detect by anybody except the end user.
ICE Posted December 15, 2003 Author Posted December 15, 2003 Anything else... just ask... Alex :D Thanks for your reply Alex but its not quite what i needed. What i want is to show or load the form that i ALREADY "designed" or made (ie has all those command butons, labels etc...) to load from the main form. With your code, its building the form "on the fly" during compilation which i dont need. Hope you understood what i mean ... :) Quote
Mehyar Posted December 15, 2003 Posted December 15, 2003 If the form already exists then it should show by itslef, if your project is showing another form then right click your project and click properties. Select your startup object. And play... If this isn't what you mean then tell me.... Quote Dream as if you'll live forever, live as if you'll die today
Administrators PlausiblyDamp Posted December 15, 2003 Administrators Posted December 15, 2003 dim frm1 as new form1() 'Should be your form name here frm1.show Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AlexCode Posted December 15, 2003 Posted December 15, 2003 Hi again ... I'm really not quite getting your point... Is it what PlausiblyDamp posted? In the code you povided you had: dim frm1 as new form() frm1.show On the first line, ...form() must be replaced by the form you want to show. Lets say you have 2 Forms, Form1 & Form2, and you whant to show Form2 within Form1 when you click a button for example... On the Button click even you have to put this: dim Form2 as Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Form2 = New Form2 Form2.show End Sub Just another thing... you can use ShowDialog instead of Show. It has more diferences but the most used, i think, it's that the code stops until the form is closed... I hoppe this is it... if not, you know... just ask! Alex :D Quote Software bugs are impossible to detect by anybody except the end user.
Mehyar Posted December 15, 2003 Posted December 15, 2003 I have a feeling that because ICE came from a vb6 background he is confused about the concept of instantiating forms before using them. If you have a from that you have designed and would like to show it at runtime as a result to the click of a button for example, then as AlexCode and PlausiblyDamp showed you, you have to create a new instance and use the Show or ShowDialogue method. Hope this helps, Quote Dream as if you'll live forever, live as if you'll die today
ICE Posted December 15, 2003 Author Posted December 15, 2003 Thanks Allot guys. Yes its exactly what AlexCode and PlausiblyDamp said. Thats what i wanted but had hard time explaining. :) When i mentioned the "dim frm1 as new form()", i thought it was only used when a new form needs to be created. Thanks again for your help guys. A book is really needed for vb .net! :) cya... edit: Great Forums! Quote
AlexCode Posted December 15, 2003 Posted December 15, 2003 edit: Great Forums! We do our best :) Alex :D Quote Software bugs are impossible to detect by anybody except the end user.
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.