Programatically hide/remove tabpages in VB.NET

我的梦境 提交于 2019-12-01 22:06:01

check this.

    For i As Integer = TextBox1.Text + 1 To 9

        Form1.TabControl1.TabPages.Remove(Form4.TabControl1.TabPages(TextBox1.Text + 1))

    Next

or

    For index As Integer = 9 To TextBox1.Text + 1 Step -1

        Me.TabControl1.TabPages.Remove(Me.TabControl1.TabPages(index))
    Next

Never use your Input unfiltered. Put the Textbix1.Text Input in a integer.tryparse construct. Also, activate Option strict for better code quality.

For your Problem:

Dim MaxVisible as Integer
Dim Sucess as Boolean
Sucess=Integer.Tryparse(textbox1.text, MaxVisible)
If Sucess=True

For index As Integer = 9 To MaxVisible  + 1 Step -1
 Me.TabControl1.TabPages(Index).visible=false
End If

That should make the unwanted tabcontrols invisible. I dont know if Tabpages(index) works, maybe you must youse getitems instead - I have no Winforms Project at hand to test it. More Information on TabControl: http://msdn.microsoft.com/de-de/library/system.windows.forms.tabcontrol.aspx

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