How do I open a file into a textbox with multiple tabs?

三世轮回 提交于 2020-01-07 03:07:08

问题


I'm creating a document writing program in VB.NET, and I can create multiple tabs. How would I open a file into the textbox that I am open on, even though I can't declare what textbox I'm using? Link to understand this better

Code for the sub:

Public Sub setText(Byval value As String)
  If tabPage1.Visible = True Then
    mainText.Text = value
  ElseIf tabPage2.Visible = True Then
    textBox1.Text = value
  End If
End Sub

Thanks in advance!


回答1:


You need to use the same type of idea you did for the getText

Dim sub setText(value as string)
  Dim mytextbox As TextBox = TabControl1.SelectedTab.Controls.OfType(Of TextBox)().First()

  mytextbox.text = value
end sub 


来源:https://stackoverflow.com/questions/34244001/how-do-i-open-a-file-into-a-textbox-with-multiple-tabs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!