Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application where i have form1 and form2 . On button click of the form1 i open the form2 in the panel placed in form1. form2 has a text box. But the text box is behaving in an abnormal manner on mouse click.
Please Help

//Form1 button click code
F = new Form2();
panel1.Controls.Add(F);
F.Dock = DockStyle.Fill;
F.BringToFront();
F.Show();

//Form2 code 
this.TopLevel = false;//Form Load
this.TextBox textbox1= new Textbox(); 
textbox1.text = "Hello";
Posted
Updated 10-Jul-11 22:51pm
v4
Comments
Sergey Alexandrovich Kryukov 11-Jul-11 4:04am    
A reason for my vote of 1: Why posting code which will not compile?! Text, not text. Do you type it manually? This is forum for software developers, if you still did not get it. Also, for a software developers there is no "not working". It needs correct and comprehensive problem report.
--SA
Saurabh.abhyankar 11-Jul-11 4:41am    
Sorry for posting the code that didnt compile . i was just trying to brief you guys of the structure of my code . Will keep that in mind for the future.
Thanks for pointing out.

What are you trying to achieve?
 
Share this answer
 
Comments
Saurabh.abhyankar 11-Jul-11 4:44am    
Hi Actually i want to add a form to the splitcontainer's panel 2. so when i add the form text box contained in the form behaves abnormaly.
[no name] 11-Jul-11 15:59pm    
Your approach is wrong. Usually, you cannot show one form within another. Why not use the textbox directly on the first form ?
This is all wrong from the very beginning. You're trying to add a form to panel. It does not work like this. Only a control should be added to a panel. No need to bring a form to front, this is also good for non-top-level controls.

All this makes no sense. Forget about adding a form into form. Use one form, after all; everything else should be its children — controls and not other forms.

—SA
 
Share this answer
 
Comments
Saurabh.abhyankar 11-Jul-11 4:39am    
Hey hi SA thanks for answering But i cant change the structure of the program and the basic question is cant i add a form which is itself a control to a panel.
And if i add it why is the textbox a control added to the form [form - which i add to the panel] behaving in the abnormal manner on the mouse button click.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900