Ribbon Fun

Knowledge based on Nugent Package: System.Windows.Forms.Ribbon35 (3.5.8)

You create Ribbon Tabs. On the Tabs, you create Panels

In the Items property, you can customize what is in each panel (like buttons, dropdowns, checkbox, etc)

** Just by double clicking in Designer, it does *not* bring you to events. You need to go into the Code editor and drop down each of the Ribbon types you want and select an event

Make a particular Tab the Active Tab

Ribbon1.ActiveTab = RibbonTab5

Handling a RibbonTab change

All of the RibbonTabs seem to fire if you don't handle it
 

    Private Sub RibbonTab2_ActiveChanged(sender As Object, e As EventArgs) Handles RibbonTab2.ActiveChanged

        Dim oRib As RibbonTab = CType(sender, RibbonTab)

        If oRib.Active Then

            TabControl1.Visible = True

            TabControl1.SelectedIndex = 0

            funGetDebtDetails()

            TabControl1.BringToFront()

        End If

    End Sub

Adding an entry to a Ribbon Drop down on the fly

The dropdown items are RibbonLabels (items). Does not work the same like a ComboBox. You have to see if it already exists. If it does not, you create a label and then add it--requery to proceed.

        Dim oRibbonLabel As New RibbonLabel()

        oRibbonLabel = cmbBank1.DropDownItems.Find(Function(Vl As RibbonLabel) Vl.Text = cmbBank1.TextBoxText)

        If oRibbonLabel Is Nothing Then

            oRibbonLabel = New RibbonLabel

            oRibbonLabel.Text = cmbBank1.TextBoxText

            cmbBank1.DropDownItems.Add(oRibbonLabel)

        End If

        oRibbonLabel = cmbBank1.DropDownItems.Find(Function(Vl As RibbonLabel) Vl.Text = cmbBank1.TextBoxText)

        Try

            cmbBank1.SelectedItem = oRibbonLabel

        Catch ex As Exception

            MsgBox("Cannot Add this account :(")

        End Try

Using the Ribbon Drop down text

cmbBank1.SelectedItem.Text

Populating a Ribbon Drop down

        While sqlReader.Read()

            Dim oRibbonLabel As New RibbonLabel()

            oRibbonLabel.Text = sqlReader("iBank").ToString

           

            Form1.cmbBank1.DropDownItems.Add(oRibbonLabel)

        End While

..



x