[英]Find Focused TextBox in a TabControl vb.net
I'm trying to add a TabControl to my text editor. 我试图将TabControl添加到我的文本编辑器。 I just need to find out how I can find the current textbox the user is editing in the tab control, so a button changes the current selected tab's text to "Hello World".
我只需要找出如何在选项卡控件中找到用户正在编辑的当前文本框,因此可以通过一个按钮将当前所选选项卡的文本更改为“ Hello World”。 The button is not located inside of the tab control.
该按钮不在选项卡控件的内部。
Below is my code for adding a new tab to the tab control, it runs on a button click. 下面是我的代码,用于向选项卡控件添加新选项卡,它在单击按钮时运行。
Dim tpTabs As New TabPage()
Dim tbText = New TextBox()
tpTabs.Name = "tpPage" & tcTabs.TabPages.Count + 1
tbText.Name = "tbText" & tcTabs.TabPages.Count + 1
tbText.Multiline = True
tbText.Dock = DockStyle.Fill
tbText.ScrollBars = ScrollBars.Both
tpTabs.Text = "Untitled"
tpTabs.Controls.Add(tbText)
tcTabs.TabPages.Add(tpTabs)
tcTabs.SelectedTab = tpTabs
So every tab opens with a new textbox. 因此,每个选项卡都会打开一个新的文本框。 New tabs are called "tpPage" followed by a number that increments one every time a new tab is made, same with textbox, "tbText" followed by a number that increments every time a new one is created.
新选项卡称为“ tpPage”,后跟一个数字,每次创建一个新选项卡时都会增加一个,与文本框相同,“ tbText”后接一个数字,每次创建一个新选项卡时都会增加。
So I want my button to change only the current tab's text currently opened to "Hello World!," then the other tabs when I get to them eventually. 因此,我希望我的按钮仅将当前打开的当前选项卡的文本更改为“ Hello World!”,然后最终更改其他选项卡。
Any help is appreciated, I've tried many things like TcTabs (which is the tab control on the form) tcTabs.SelectedTab.tbText.Text = "Hello World!," but I can't find a solution. 感谢您的帮助,我已经尝试了许多方法,例如TcTabs(窗体上的选项卡控件)tcTabs.SelectedTab.tbText.Text =“ Hello World!”,但我找不到解决方案。
CType(tcTabs.SelectedTab.Controls.Item(0),TextBox).Text =“ Hello World”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.