如何关注用户控件的控件? [英] How to focus on User Controls's control?
本文介绍了如何关注用户控件的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下控件创建了一个User控件。
SplitContainer - Panel1 - Richtextbox1
- Panel2 - Richtextbox2
我想在formload上集中控制Richtextbox2 ..如何设置焦点?
任何人都可以帮我吗?
我尝试使用此代码..没有工作
I created a User control with the following controls.
SplitContainer - Panel1 - Richtextbox1
- Panel2 - Richtextbox2
I want to focus control of Richtextbox2 on formload.. How to set focus ?
Can anyone help me out?
I tried with this code..its not working
splitContainer1.Focus();
splitContainer1.ActiveControl = Richtextbox2;
推荐答案
您无法将Focus设置为无法接受用户的控件输入。
所以试试这个:
You can't set the Focus to an control that can't accept user input.
So try this:
richTextBox2.Focus();
但是当我尝试你的代码时,两种形式都可以正常工作......
But when I tried your code, both forms work fine...
这篇关于如何关注用户控件的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文