Please Help With toolstrip
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Hello I am trying to make a tool strip clear all controls bare three so with some help came up with this
Code: Select all
But It is not working everything loads but when I press the button for it it just brings up the message box and then excutes the finally command Try
For Each tsi As ToolStripItem In ToolStrip1.Items
If TypeOf tsi Is ToolStripButton And tsi.Text = "2" Or tsi.Text = "1" Or tsi.Name = "ToolStripSeparator3" Then
Else
ToolStrip1.Items.Remove(tsi)
End If
Next
For Each tsi As ToolStripItem In ToolStrip1.Items
If TypeOf tsi Is ToolStripButton And tsi.Text = "1" Or "2" Then
Else
ToolStrip1.Items.Remove(tsi)
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Faves.Items.Add(ComboBox1.Text)
Dim btnTop As Integer = 0
For i As Integer = 0 To Faves.Items.Count - 1
Dim btn As New ToolStripButton
btn.Text = Faves.Items(i).ToString()
btn.ForeColor = Color.White
btn.BackColor = Color.FromArgb(60, 60, 60)
btn.Tag = i
AddHandler btn.Click, AddressOf btnclicked
ToolStrip1.Items.Add(btn)
btnTop += 30
Next
End Try
You could use ToolStrip1.Items.RemoveAt inside a for/while loop to remove a range of items.
Would you mind giving me a demonstration as I am not completely sure what you mean removeAT as far as I know toolstrip does not have this capability
you can use this
Code: Select all
while toolstrip.items.count > 3
Tolstrip.items.removeat(3)
End while
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023