Textbox in a from that is loaded into a Panlel Mouse select on txtbox not working

B

Brano

Hi I am using vb.net 2005 this is a windows application

I am using this functionality in another project I have created this
simple project to show the problem


Basically I have two forms:


Form1 - contains a panel (System.Windows.Forms.Panel)
Form2 - contains two textboxes with some sample text in them


If the Form2 is executed on its own the textboxes work fine you can
use your mouse to select a portion of the text and copy paste it


However if I run the Form2 in a panel in Form1 the functionality of
the textboxes is gone you can no longer use the mouse to select parts
of the text you can only souble click to select the whole contents of
the textbox.


this is the code I am using:


Code:


Public Class Form1


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


Dim frmToDisplay As New Form2


frmToDisplay.TopLevel = False
Panel1.Controls.Clear()
Panel1.Controls.Add(frmToDisplay)
frmToDisplay.Show()
frmToDisplay.Activate()


End Sub
End Class


Does anyone know id this is a bug with VB 2005 or am I doing
something
wrong?


THANKS
 
A

Armin Zingler

Brano said:
Hi I am using vb.net 2005 this is a windows application

I am using this functionality in another project I have created this
simple project to show the problem


Basically I have two forms:


Form1 - contains a panel (System.Windows.Forms.Panel)
Form2 - contains two textboxes with some sample text in them


If the Form2 is executed on its own the textboxes work fine you can
use your mouse to select a portion of the text and copy paste it


However if I run the Form2 in a panel in Form1 the functionality of
the textboxes is gone you can no longer use the mouse to select parts
of the text you can only souble click to select the whole contents of
the textbox.


this is the code I am using:


Code:


Public Class Form1


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


Dim frmToDisplay As New Form2


frmToDisplay.TopLevel = False
Panel1.Controls.Clear()
Panel1.Controls.Add(frmToDisplay)
frmToDisplay.Show()
frmToDisplay.Activate()


End Sub
End Class


Does anyone know id this is a bug with VB 2005 or am I doing
something
wrong?

Form's inside other Forms is not supported, unless it's an MDI
application. Use Usercontrols instead.


Armin
 
C

CodeMonkey

Brano said:
Hi I am using vb.net 2005 this is a windows application

I am using this functionality in another project I have created this
simple project to show the problem


Basically I have two forms:


Form1 - contains a panel (System.Windows.Forms.Panel)
Form2 - contains two textboxes with some sample text in them


If the Form2 is executed on its own the textboxes work fine you can
use your mouse to select a portion of the text and copy paste it


However if I run the Form2 in a panel in Form1 the functionality of
the textboxes is gone you can no longer use the mouse to select parts
of the text you can only souble click to select the whole contents of
the textbox.


this is the code I am using:


Code:


Public Class Form1


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


Dim frmToDisplay As New Form2


frmToDisplay.TopLevel = False
Panel1.Controls.Clear()
Panel1.Controls.Add(frmToDisplay)
frmToDisplay.Show()
frmToDisplay.Activate()


End Sub
End Class


Does anyone know id this is a bug with VB 2005 or am I doing
something
wrong?


THANKS

I just tried this and it works for me. I have SP1 installed, do you?
 
C

CodeMonkey

Brano said:
Hi thanks Yeah I do and it doesnt work could you try my project?

here is the link

http://www.motounlock.net/BigJohn/PanelTestWinForms.zip


But can you go to the textbox and select a part of the text using
mouse?



THX


I downloaded your project and it does exactly what you say it does. I
cannot select text. I opened my project back up and verified it does
work correctly, however my project isn't like yours... I mistakingly
used all of our custom components. We use components from Developer's
Express... It's interesting, though. I took out one line of code to
enable form based skins, and it doesn't work right. If I put that line
of code back in, the mouse works correctly, even with the default
context menu.

I'm not sure what to tell you. Hopefully someone else will chime in with
some advice.
 
B

Brano

Hi it is an MDI application the isMDIContainer property of the parent
form is set to true and I have even tried this

frmToDisplay.Parent = Me

Is there something I am missing to make it an MDI application?
 
B

Brano

Hi it is an MDI application the isMDIContainer property of the parent
form is set to true and I have even tried this

frmToDisplay.Parent = Me

Is there something I am missing to make it an MDI application?2005
this is a windows application
 
A

Armin Zingler

Brano said:
Hi it is an MDI application the isMDIContainer property of the
parent form is set to true and I have even tried this

frmToDisplay.Parent = Me

Is there something I am missing to make it an MDI application?2005
this is a windows application

Replace by:
frmToDisplay.MdiParent = Me

No need to change TopLevel property.


Armin
 
A

Armin Zingler

Brano said:
Yes if I do that there is no need to change the TopLevel property
but it still doesn't work you still cant select the contents of the
textbox by mouse.

Because you wrote "frmToDisplay.parent = me" I assumed that you do not
execute "Panel1.Controls.Add(frmToDisplay)" anymore, because both at one
time doesn't make sense. But I guess you still try to put it into a panel in
the MDI container. You mustn't do this. The MDI Form must be put in the MDI
containers client area (by setting the MDIparent property).


Armin
 
B

Brano

Hi,

thanks for your help but I think you have misunderstood what I am
trying to do here.

The way you suggests it works and the textboxes are selectable (if I
use only MDIcontainer and make the form2 chid of it) but this isn't
what I was after at all

I need to use the panel control because I have in my main application
a treeview that I am using for navigation thru the application (this
is not included in this sample application)

So regardles of the MDI my problem is that once the form is added to
the panel using this statements:

Panel1.Controls.Add(frmToDisplay)

The textboxes on the form are no longer selectable by mouse.

I understand your point about the MDI forms but this is not what I am
after as I need to use the fuctionality of the panel...
 
A

Armin Zingler

Brano said:
Hi,

thanks for your help but I think you have misunderstood what I am
trying to do here.

The way you suggests it works and the textboxes are selectable (if I
use only MDIcontainer and make the form2 chid of it) but this isn't
what I was after at all

I need to use the panel control because I have in my main
application a treeview that I am using for navigation thru the
application (this is not included in this sample application)

So regardles of the MDI my problem is that once the form is added to
the panel using this statements:

Panel1.Controls.Add(frmToDisplay)

The textboxes on the form are no longer selectable by mouse.

I understand your point about the MDI forms but this is not what I
am after as I need to use the fuctionality of the panel...

I did undestand what you are trying, but I was trying to tell you that you
can not put Forms inside other Forms unless it's an MDI child form inside a
MDI container. I meant directly inside as a MDI child. If you put the Form
into a panel, it's not an MDI child anymore. As you see now, your approach
creates side effects because this is not supported.


Armin
 
B

Brano

So you are saying that putting a form into a panel is not supported? I
think this is a bug in visual studio more than anything because you
either should not be able to do it at all or it should work without
side effects (bugz) anyone from MS to comment on this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top