Back to Devexpress

RibbonForm.NavigationControlLayoutMode Property

windowsforms-devexpress-dot-xtrabars-dot-ribbon-dot-ribbonform-2cc948fd.md

latest5.5 KB
Original Source

RibbonForm.NavigationControlLayoutMode Property

Gets or sets the alignment of the side navigation relative to the form’s title.

Namespace : DevExpress.XtraBars.Ribbon

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(RibbonFormNavigationControlLayoutMode.Default)]
[DXCategory("Appearance")]
public RibbonFormNavigationControlLayoutMode NavigationControlLayoutMode { get; set; }
vb
<DXCategory("Appearance")>
<DefaultValue(RibbonFormNavigationControlLayoutMode.Default)>
Public Property NavigationControlLayoutMode As RibbonFormNavigationControlLayoutMode

Property Value

TypeDefaultDescription
RibbonFormNavigationControlLayoutModeDefault

A value that specifies the alignment of the side navigation relative to the form’s title.

|

Available values:

NameDescription
Default

The navigation control stretches from the top to the bottom of the form (full height).

| | StretchToTop |

The navigation control stretches from the top to the bottom of the form (full height).

| | StretchToFormTitle |

The navigation control starts below the form’s title and extends to the bottom of the form.

|

Remarks

The following code snippet creates a side navigation inspired by the new Microsoft Outlook:

csharp
using DevExpress.XtraBars.Navigation;
using DevExpress.XtraBars.Ribbon;
using System.Windows.Forms;

namespace DXApplication {
    public partial class Form1 : RibbonForm {
        AccordionControl accordion;
        public Form1() {
            InitializeComponent();
            accordion = new AccordionControl() { Dock = DockStyle.Left };
            this.Controls.Add(accordion);
            this.NavigationControl = accordion;
            this.NavigationControlLayoutMode = RibbonFormNavigationControlLayoutMode.StretchToFormTitle;
            CreateAccordionItems();
        }
        void CreateAccordionItems() {
            AccordionControlElement group1 = new AccordionControlElement(ElementStyle.Group) {
                Name = "group1",
                Text = "Contacts",
                Expanded = true
            };
            AccordionControlElement item1 = new AccordionControlElement(ElementStyle.Item) {
                Name = "itemCustomers",
                Text = "Customers",
            };
            AccordionControlElement item2 = new AccordionControlElement(ElementStyle.Item) {
                Name = "itemEmployees",
                Text = "Employees"
            };

            group1.Elements.AddRange(new AccordionControlElement[] { item1, item2 });
            accordion.Elements.Add(group1);
        }
    }
}
vb
Imports DevExpress.XtraBars.Navigation
Imports DevExpress.XtraBars.Ribbon
Imports System.Windows.Forms

Namespace DXApplication
    Public Partial Class Form1
        Inherits RibbonForm

        Private accordion As AccordionControl

        Public Sub New()
            InitializeComponent()
            accordion = New AccordionControl() With {.Dock = DockStyle.Left}
            Me.Controls.Add(accordion)
            Me.NavigationControl = accordion
            Me.NavigationControlLayoutMode = RibbonFormNavigationControlLayoutMode.StretchToFormTitle
            CreateAccordionItems()
        End Sub

        Private Sub CreateAccordionItems()
            Dim group1 As New AccordionControlElement(ElementStyle.Group) With {
                .Name = "group1",
                .Text = "Contacts",
                .Expanded = True
            }
            Dim item1 As New AccordionControlElement(ElementStyle.Item) With {
                .Name = "itemCustomers",
                .Text = "Customers"
            }
            Dim item2 As New AccordionControlElement(ElementStyle.Item) With {
                .Name = "itemEmployees",
                .Text = "Employees"
            }

            group1.Elements.AddRange(New AccordionControlElement() {item1, item2})
            accordion.Elements.Add(group1)
        End Sub
    End Class
End Namespace

Note

Automatic layout adjustments of the RibbonStatusBar (based on the NavigationControlLayoutMode property) are applied only if the status bar is a direct child of the RibbonForm.

If the status bar is placed inside another container (for example, a Panel), it will not respond to layout changes triggered by the navigation control. To ensure correct behavior, add the RibbonStatusBar directly to the form.

See Also

RibbonForm Class

RibbonForm Members

DevExpress.XtraBars.Ribbon Namespace