I have a form with several controls. It includes a tabstrip with one tab. I allow users to add tabs, by clicking commandbutton1. So far so well.
我有一个有几个控件的表单。它包含一个带一个选项卡的选项卡。我允许用户通过单击commandbutton1添加选项卡。到目前为止。
Now I also want users to be able to remove the last tab (except for the first one) by clicking commandbutton2. The problem is that, despite the fact that I've been searching for about two hours, I cannot find the right syntax for method "remove" when it comes to tabs. Any help appresiated.
现在,我还希望用户能够通过单击commandbutton2删除最后一个选项卡(除了第一个选项卡)。问题是,尽管我已经搜索了大约两个小时,但当涉及到制表符时,我无法找到正确的方法“删除”语法。任何帮助appresiated。
edited:
编辑:
Making the above question more specific: What's the right syntax for "remove" method when it's parameter is a string-variable and not a specific tab name. (for example removing the current tab)
使上述问题更加具体:当参数是字符串变量而不是特定的选项卡名称时,“删除”方法的正确语法是什么?(例如删除当前选项卡)
e.g. It would be great if one of the following would work:
如果下列方法之一有效那就太好了:
Sub test
Dim nm As String
With TabStrip1
nm = .SelectedItem.Name
.Tabs.Remove (nm)
End With
End Sub
or
或
Sub test
With TabStrip1
.Tabs.Remove (.SelectedItem.Name)
End With
End Sub
2 个解决方案
#1
0
Hi you can Remove a Tab by the TabStrip1.Tabs.Remove
Line.
你好,可以通过TabStrip1.Tabs删除一个选项卡。删除线。
Private Sub CommandButton1_Click() 'Insert the Tap Test
TabStrip1.Tabs.Add ("Test")
End Sub
Private Sub CommandButton2_Click()'Removes the Tap Test
TabStrip1.Tabs.Remove ("Test")
End Sub
The Rest you can Handle with a something Like this:
剩下的你可以用这样的东西来处理:
If TabStrip1.Tabs.Count >= 2 Then
TabStrip1.Tabs.Remove (TabStrip1.Tabs.Count - 1)
End If
You have to check fist if there are more then two Taps. If yes delete the last Tap. The Hint her is, that the Index starts with the Second Tap!
如果有两个水龙头,你得先检查一下。如果是,请删除最后一个。她的暗示是,索引从第二次点击开始!
#2
1
Finally found the way. remove
method accepts a tab's caption
as an argument and not its name
.
终于找到了。remove方法接受一个选项卡的标题作为参数,而不是它的名称。
In this case the following worked great:
在这种情况下,以下方法非常有效:
Private Sub CommandButton2_Click()
Dim nm As String
With TabStrip1
nm = .SelectedItem.Caption
.Tabs.Remove (nm)
End With
End Sub
or
或
Private Sub CommandButton2_Click()
With TabStrip1
.Tabs.Remove (.SelectedItem.Caption)
End With
End Sub
#1
0
Hi you can Remove a Tab by the TabStrip1.Tabs.Remove
Line.
你好,可以通过TabStrip1.Tabs删除一个选项卡。删除线。
Private Sub CommandButton1_Click() 'Insert the Tap Test
TabStrip1.Tabs.Add ("Test")
End Sub
Private Sub CommandButton2_Click()'Removes the Tap Test
TabStrip1.Tabs.Remove ("Test")
End Sub
The Rest you can Handle with a something Like this:
剩下的你可以用这样的东西来处理:
If TabStrip1.Tabs.Count >= 2 Then
TabStrip1.Tabs.Remove (TabStrip1.Tabs.Count - 1)
End If
You have to check fist if there are more then two Taps. If yes delete the last Tap. The Hint her is, that the Index starts with the Second Tap!
如果有两个水龙头,你得先检查一下。如果是,请删除最后一个。她的暗示是,索引从第二次点击开始!
#2
1
Finally found the way. remove
method accepts a tab's caption
as an argument and not its name
.
终于找到了。remove方法接受一个选项卡的标题作为参数,而不是它的名称。
In this case the following worked great:
在这种情况下,以下方法非常有效:
Private Sub CommandButton2_Click()
Dim nm As String
With TabStrip1
nm = .SelectedItem.Caption
.Tabs.Remove (nm)
End With
End Sub
or
或
Private Sub CommandButton2_Click()
With TabStrip1
.Tabs.Remove (.SelectedItem.Caption)
End With
End Sub