问题访问面板中放置的表单中的文本框 [英] Problem Accesing a textbox in the form that is placed in the panel

查看:89
本文介绍了问题访问面板中放置的表单中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有form1和form2的应用程序.在单击form1的按钮上,我在位于form1的面板中打开form2. form2有一个文本框.但是鼠标单击时,文本框的行为异常.
请帮助

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";

推荐答案

您要达到什么目的?


从一开始这都是错误的.您正在尝试向面板添加表单.它不能像这样工作.仅控件应添加到面板中.无需将表单放在最前面,这对于非顶级控件也很有用.

所有这些都没有道理.忘记将表单添加到表单中了.毕竟使用一种形式;其他所有东西都应该是它的子元素-控件而不是其他形式.

—SA
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


这篇关于问题访问面板中放置的表单中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆