nta1

Hi,

I have a windows application written in vb .net.

There are 2 forms in the application: form1, form2, where form1 loads form2 and form2 contains a text box.

when I load form2 from form1 in this way:

Code Block

Dim frm2 As New Form2

frm2.BringToFront()

frm2.Show()

everything works o.k.

but when I try it this way:

Code Block

Dim frm2 As New Form2

frm2.TopLevel = False

frm2.Parent = Me 'Me=form1

frm2.BringToFront()

frm2.Show()

I can't select text (using the mouse) inside the text box - the only thing I can do is select the entire text in the text box by double clicking on it.

why does it happen and how can it be solved (assuming I want form1 to be form2's parent)

Thanks a lot,

nta1.



Re: Windows Forms General selecting text in a text box

Stephan Smetsers

hi,

It seems you are trying to do something for which UserControls were designed. UserControls are 'forms' that can be designed in the IDE just like normal WinForms and can be dropped on other forms (and even on other usercontrols) using the visual studio tool palette.

For more information:

Try create one by right click on your project in the solution explorer of visual studio | Add | User Control

After compilation your control should appear in the tool palette.

Stephan





Re: Windows Forms General selecting text in a text box

nta1

Thanks,

but can I have my userControl look like a form- specifically, can it have the minimize, maximize and close boxes





Re: Windows Forms General selecting text in a text box

Stephan Smetsers

hi,

No you can not. But if you put it into a panel that is collapsable, you can simulate this behaviour. Ps. Collapsable panels are not standard controls of .NET framework. So you might need to create one yourself or buy a thrid party control.

Stephan





Re: Windows Forms General selecting text in a text box

nta1

thanks,

but eventually i solved it in a bit different way:

Code Block

Dim frm2 As New Form2

frm2.BringToFront()

frm2.Show(Me) 'Me = Form1

frm2.ShowInTaskbar = False

that's pretty much answers all my demands...





Re: Windows Forms General selecting text in a text box

Stephan Smetsers

hi,

I never used that overload, but if it works,.... it works!

Stephan