put textbox, scrollbar on the second forms

CharlieChau

Active member
Joined
Jun 15, 2004
Messages
26
Programming Experience
Beginner
How can I use the toolbox to put more control (textbox, list box, checkbox,etc) on the second form which is activated by a button of the first form as

Dim frmForm2 As Form2 = New Form2()
frmForm2.Show()
 
CharlieChau said:
How can I use the toolbox to put more control (textbox, list box, checkbox,etc) on the second form which is activated by a button of the first form as

Dim frmForm2 As Form2 = New Form2()
frmForm2.Show()
what do you mean by putting more controls in your form2?
just go in your form2 design and put it there the controls you want...


is that what you mean?
if not sorry
 
I created the second form by using the two lines of code:

Dim frmForm2 As Form2 = New Form2()
frmForm2.Show()

How can I use the GUI from the toolbox to put textbox, scrollbar, etc in my second form. Can I use the GUI toolbox to create the second form, how can I do it.

If I can not do it by GUI, can you give me some code examples to put a textbox in the second form.

thanks,
CC.
 
You need to create the form first

I can't remember exact menu names, but something like...

Project-->Add Form-->Windows Form


Now you can do the GUI just like your first form




Hope thats what you needed
 
CC,

You are mixing up design time and run time. You can only use the toolbox at design time. In this case, you can add a second form to your project, add any GUI components you want and then run the application. The startup form can be used to show the second form using the run-time code like you showed in your original post. This is the most typical scenario and likely what you want to do.

If you want to both create a new form and add components at run time, you need to write code to not only instantiate your new form, but also add the components (a fairly complex task and one that is likely not what you want to do).

bill burrows


CharlieChau said:
I created the second form by using the two lines of code:

Dim frmForm2 As Form2 = New Form2()
frmForm2.Show()

How can I use the GUI from the toolbox to put textbox, scrollbar, etc in my second form. Can I use the GUI toolbox to create the second form, how can I do it.

If I can not do it by GUI, can you give me some code examples to put a textbox in the second form.

thanks,
CC.
 
CharlieChau said:
I created the second form by using the two lines of code:

Dim frmForm2 As Form2 = New Form2()
frmForm2.Show()

How can I use the GUI from the toolbox to put textbox, scrollbar, etc in my second form. Can I use the GUI toolbox to create the second form, how can I do it.

If I can not do it by GUI, can you give me some code examples to put a textbox in the second form.

thanks,
CC.
just add another windowsforms in your project and in the design mode you can put controls what you want..

and if you want to put textbox in your form2 while it is running..
put a button click event in your form2.
in your button click
VB.NET:
 dim textbox1 as Textbox = new Textbox()
 'put the location of the textbox
 textbox1.location = System.Drawing.Point(16, 0)
 'name of the textbox
 textbox1.name = "txtname"
 textbox1.text = " "
 'add the textbox in the form2
 me.controls.add(textbox1)
is that what you want??
if not sory
 
I preferred the suggestion of nervous-rex. I used the Project-->Add Form-->Windows Form to create the second form and put the control options on this second form.

Now, I want to use the button in the first form to activate the second form as
"Form2.ActiveForm". I can not compile it. How can I make it work, since they are two different objects.

The second problem, when the mouse is moving above my button (I do not click yet), I want an dialog box to display 2 or 3 lines to explain the functionalily of that button. How can I do it?

Thanks,
CC.
 
I haven't used window forms for a while, but I believe the code you were originally using would be what you need to do in the button click event, where Form2 is the actual name of the form you created

Dim frmForm2 As Form2 = New Form2()
frmForm2.Show()


As far as the dialog describing the button, does the button have tooltip property, if so that is where you would state what it does, like I said, been a while since I have made a windows form, sorry not more help there.
 
To use tooltips, you need to add the ToolTip control. Then you can set the tooltip property for the button.

As an alternative method, you could use a statusBar control and the button MouseEnter and MouseLeave events to change the StatusBar text accordingly.
 
Originally posted by CharlieChau
The second problem, when the mouse is moving above my button (I do not click yet), I want an dialog box to display 2 or 3 lines to explain the functionalily of that button. How can I do it?
if i were you follow Paszt suggestions..
it will help you to get started...
 
Back
Top