Public Class Form1
Dim rrt(3) As ToolStripItem
Dim rrs(4) As ToolStripItem
Dim rru(2) As ToolStripItem
Dim langs(100) As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i = 0 To 12 'Use the strings in the DataGridView for the dialog
If DataGridView1.Item(1, i).Value = Nothing Then
DataGridView1.Item(1, i).Value = String.Empty
End If
langs(i) = DataGridView1.Item(1, i).Value.ToString
Next
Dim result = UserCustomizableToolStrip.ShowCustomizeToolbarWindow(ToolStrip1, rrt, "|nieuw|openen", langs)
TextBox1.Text = result
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
MsgBox("openen") 'Just an event so that you can see it remains when a button is moved, removed or added
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
UserCustomizableToolStrip.UpdateToolStripWithString(ToolStrip1, rrt, TextBox1.Text) 'Update the ToolStrip with the contents of the TextBox
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
My.Settings.ToolStripButtons = TextBox1.Text 'Save the current setting of the ToolStrip
My.Settings.StatusStripButtons = TextBox2.Text
My.Settings.MenuStripButtons = TextBox3.Text
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGridView1.Rows.Add(New String() {"Label1", "Available Buttons:"})
DataGridView1.Rows.Add(New String() {"Label2", "Current Buttons:"})
DataGridView1.Rows.Add(New String() {"Button1", "OK"})
DataGridView1.Rows.Add(New String() {"Button2", "Cancel"})
DataGridView1.Rows.Add(New String() {"Button3", "Reset"})
DataGridView1.Rows.Add(New String() {"Button4", "Move Up"})
DataGridView1.Rows.Add(New String() {"Button5", "Move Down"})
DataGridView1.Rows.Add(New String() {"Button6", "Add ->"})
DataGridView1.Rows.Add(New String() {"Button7", "<- Remove"})
DataGridView1.Rows.Add(New String() {"Window Title", "Customize Toolbar"})
DataGridView1.Rows.Add(New String() {"Translation for 'separator'", "Separator"})
DataGridView1.Rows.Add(New String() {"Reset warning text", "Are you sure you want to reset the toolbar?"})
DataGridView1.Rows.Add(New String() {"Reset warning title", "Warning"})
rrt(0) = ToolStripButton1 'Update the variables containing avaiable buttons for the 3 Strips
rrt(1) = ToolStripButton2
rrt(2) = ToolStripButton3
'rrt(3) = ToolStripSeparator1 'Isn't needed since separators with the default values are made by the function
rrt(3) = ToolStripDropDownButton1
rrs(0) = TestToolStripMenuItem2
rrs(1) = FooToolStripMenuItem1
rrs(2) = BarToolStripMenuItem1
rrs(3) = ToolStripTextBox1
rrs(4) = ToolStripComboBox2
rru(0) = ToolStripStatusLabel1
rru(1) = ToolStripProgressBar1
rru(2) = ToolStripDropDownButton2
My.Settings.Reload()
UserCustomizableToolStrip.UpdateToolStripWithString(ToolStrip1, rrt, My.Settings.ToolStripButtons) 'Reload ToolStrip with saved setting
UserCustomizableToolStrip.UpdateToolStripWithString(StatusStrip1, rru, My.Settings.StatusStripButtons)
UserCustomizableToolStrip.UpdateToolStripWithString(MenuStrip1, rrs, My.Settings.MenuStripButtons)
TextBox1.Text = My.Settings.ToolStripButtons 'Reload setting
TextBox2.Text = My.Settings.StatusStripButtons
TextBox3.Text = My.Settings.MenuStripButtons
End Sub
Private Sub CustomizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomizeToolStripMenuItem.Click
Button1_Click(sender, e)
End Sub
Private Sub CustomizeToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomizeToolStripMenuItem1.Click
TextBox3.Text = UserCustomizableToolStrip.ShowCustomizeToolbarWindow(MenuStrip1, rrs, "|nieuw")
End Sub
Private Sub CustomizeToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomizeToolStripMenuItem2.Click
TextBox2.Text = UserCustomizableToolStrip.ShowCustomizeToolbarWindow(StatusStrip1, rru, "|nieuw")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
CustomizeToolStripMenuItem1_Click(sender, e)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
CustomizeToolStripMenuItem2_Click(sender, e)
End Sub
End Class