当我删除tabcontrol中的第一个tabpage时发生了什么 [英] What happened when I delete the first tabpage in the tabcontrol

查看:72
本文介绍了当我删除tabcontrol中的第一个tabpage时发生了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有TabControl的Form,其中包含3个TabPage。

当我删除第二个或第三个TabPage时,光标将位于TabControl上不具有最小TabIndex的文本框上。但是当我删除第一个时,将选择第一个

TabPage(这意味着光标位于TabPage上)。我不知道为什么?谁能解释一下?我真的希望它仍然专注于不在TabControl上的文本框,并且具有最小的TabIndex。



我尝试了什么:



我尝试在删除TabPage之前使用Form.GetNextControl获取下一个将要选择的下一个控件,并将焦点设置为此。它工作,但我不认为这是最好的解决方案。

I have a Form with a TabControl which contain 3 TabPage.
When I remove the second or third TabPage, the cursor will be on a textbox that is not on the TabControl and has smallest TabIndex. But when I remove the first one, the first
TabPage will be selected (It mean the cursor is on the TabPage). I don't know why? Can anyone explain? I really want it still focus on the textbox which is not on the TabControl and has smallest TabIndex.

What I have tried:

I try to get the next control which will be selected next by using Form.GetNextControl before remove the TabPage and set focus to this. It work but i don't think this is the best solution.

推荐答案

我找到了适合我的东西,但不知道它是否适合你。


在onload活动中
尝试使用

i found something that worked for me, but don't know if it will work for you.

in the onload event try using
tabcontrol1.tabpages.remove(tabpage1)
tabcontrol1.visible = false
tabcontrol1.visible = true





这很奇怪,但确实有效。



it's strange, but it does work.


这篇关于当我删除tabcontrol中的第一个tabpage时发生了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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