DevComponents.com

How To Create NavigationPane Buttons Using Code

Following code illustrates how to create the NavigationPane panel and the button, connect them and add them to the NavigationPane control:

 

 

Private Sub CreateNewPanel()
        Dim button As DevComponents.DotNetBar.ButtonItem
        button = New DevComponents.DotNetBar.ButtonItem()
        button.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText
 
        ' Assign your image here instead of taking one from existing buttons
        button.Image = CType(ButtonItem1.Image.Clone(), Image)
        button.Name = "newButton"
        button.OptionGroup = "navBar"
        button.Text = "New Item"
 
        ' Setup panel which is connected to button and acts as container for other controls
        Dim panel As DevComponents.DotNetBar.NavigationPanePanel
        panel = New DevComponents.DotNetBar.NavigationPanePanel()
        panel.AntiAlias = True
        ' Add any controls to the panel by adding them to the Controls collection
        panel.Dock = System.Windows.Forms.DockStyle.Fill
        panel.DockPadding.Left = 1
        panel.DockPadding.Right = 1
        panel.DockPadding.Top = 1
        panel.Location = New System.Drawing.Point(0, 24)
        ' Connect panel and the button
        panel.ParentItem = button
        panel.Size = New System.Drawing.Size(184, 214)
        panel.Style.Alignment = System.Drawing.StringAlignment.Center
        panel.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground
        panel.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2
        panel.Style.BackgroundImagePosition = DevComponents.DotNetBar.eBackgroundImagePosition.Tile
        panel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine
        panel.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        panel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText
        panel.Style.GradientAngle = 90
        panel.StyleMouseDown.Alignment = System.Drawing.StringAlignment.Center
        panel.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center
        Me.NavigationPane1.Controls.Add(panel)
 
        Me.NavigationPane1.Items.Add(button)
 
        Me.NavigationPane1.RecalcLayout()
 
        ' Select newly created panel
        button.Checked = True
    End Sub

Sample attached below shows this code in action.

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favoritesAdd to favorites

User Opinions (10 votes)

60% thumbs up 40% thumbs down

How would you rate this answer?

Helpful
Not helpful
Thank you for rating this answer.

Related Questions

No related questions were found.

Attachments