windowsforms-devexpress-dot-xtrabars-dot-ribbon-dot-ribboncontrol-52895a03.md
Gets or sets the currently selected page.
Namespace : DevExpress.XtraBars.Ribbon
Assembly : DevExpress.XtraBars.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[Browsable(false)]
[DefaultValue(null)]
public RibbonPage SelectedPage { get; set; }
<DefaultValue(Nothing)>
<Browsable(False)>
Public Property SelectedPage As RibbonPage
| Type | Default | Description |
|---|---|---|
| RibbonPage | null |
A RibbonPage object that represents the page currently selected. null ( Nothing in Visual Basic) if the RibbonControl.Pages collection is empty.
|
If the current ribbon is merged with another ribbon as a child, use the RibbonControl.SelectPage method.
The following example creates the DevExpress WinForms Ribbon Control with two contextual tabs/pages. The svgImageCollection1 was added and populated with SVG images at design time.
using System.Drawing;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors;
namespace DXApplication19
{
public partial class Form1 : XtraForm
{
public Form1()
{
InitializeComponent();
// Create a RibbonControl.
RibbonControl Ribbon = new RibbonControl();
// Create the 'Home' page.
RibbonPage pageHome = new RibbonPage("Home");
Ribbon.Pages.Add(pageHome);
// Create the 'Selection' page category.
RibbonPageCategory catSelection = new RibbonPageCategory("Selection", Color.Orange, false);
Ribbon.PageCategories.Add(catSelection);
// Create 'Format' an 'Clipboard' contextual pages/tabs in the 'Selection' page category.
RibbonPage contextPageFormat = new RibbonPage("Format");
RibbonPage contextPageClipboard = new RibbonPage("Clipboard");
catSelection.Pages.AddRange(new RibbonPage[] { contextPageFormat, contextPageClipboard });
// Add the 'Edit' group with two bar items to the 'Format' page.
RibbonPageGroup groupEdit = new RibbonPageGroup("Edit") { AllowTextClipping = false };
// Add two bar items to the 'Edit' group.
BarButtonItem itemCopy = new BarButtonItem(Ribbon.Manager, "Copy"){ RibbonStyle = RibbonItemStyles.Large};
itemCopy.ImageOptions.SvgImage = svgImageCollection1["copy"];
BarButtonItem itemCut = new BarButtonItem(Ribbon.Manager, "Cut") { RibbonStyle = RibbonItemStyles.Large };
itemCut.ImageOptions.SvgImage = svgImageCollection1["cut"];
groupEdit.ItemLinks.AddRange(new BarItem[] { itemCopy, itemCut });
contextPageFormat.Groups.Add(groupEdit);
Ribbon.ItemClick += new ItemClickEventHandler(Ribbon_ItemClick);
// Add the RibbonControl to the form.
this.Controls.Add(Ribbon);
/* Contextual pages are hidden by default.
* The following line displays the 'Selection' page category.
*/
catSelection.Visible = true;
// Activate the 'Format' contextual page/tab.
Ribbon.SelectedPage = catSelection.Pages["Format"];
}
void Ribbon_ItemClick(object sender, ItemClickEventArgs e)
{
// Add your code to handle clicks on bar items.
}
}
}
Imports System.Drawing
Imports DevExpress.XtraBars
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraEditors
Namespace DXApplication19
Partial Public Class Form1
Inherits XtraForm
Public Sub New()
InitializeComponent()
' Create a RibbonControl.
Dim Ribbon As New RibbonControl()
' Create the 'Home' page.
Dim pageHome As New RibbonPage("Home")
Ribbon.Pages.Add(pageHome)
' Create the 'Selection' page category.
Dim catSelection As New RibbonPageCategory("Selection", Color.Orange, False)
Ribbon.PageCategories.Add(catSelection)
' Create 'Format' an 'Clipboard' contextual pages/tabs in the 'Selection' page category.
Dim contextPageFormat As New RibbonPage("Format")
Dim contextPageClipboard As New RibbonPage("Clipboard")
catSelection.Pages.AddRange(New RibbonPage() { contextPageFormat, contextPageClipboard })
' Add the 'Edit' group with two bar items to the 'Format' page.
Dim groupEdit As New RibbonPageGroup("Edit") With {.AllowTextClipping = False}
' Add two bar items to the 'Edit' group.
Dim itemCopy As New BarButtonItem(Ribbon.Manager, "Copy") With {.RibbonStyle = RibbonItemStyles.Large}
itemCopy.ImageOptions.SvgImage = svgImageCollection1("copy")
Dim itemCut As New BarButtonItem(Ribbon.Manager, "Cut") With {.RibbonStyle = RibbonItemStyles.Large}
itemCut.ImageOptions.SvgImage = svgImageCollection1("cut")
groupEdit.ItemLinks.AddRange(New BarItem() { itemCopy, itemCut })
contextPageFormat.Groups.Add(groupEdit)
AddHandler Ribbon.ItemClick, AddressOf Ribbon_ItemClick
' Add the RibbonControl to the form.
Me.Controls.Add(Ribbon)
' Contextual pages are hidden by default.
' * The following line displays the 'Selection' page category.
'
catSelection.Visible = True
' Activate the 'Format' contextual page/tab.
Ribbon.SelectedPage = catSelection.Pages("Format")
End Sub
Private Sub Ribbon_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
' Add your code to handle clicks on bar items.
End Sub
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectedPage property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-spreadsheet-use-cell-range-as-data-source/CS/RangeDataSource/Form1.cs#L15
spreadsheetControl1.LoadDocument("temperature.xlsx");
ribbonControl1.SelectedPage = dataRibbonPage1;
}
winforms-rich-edit-implement-ms-office-word-format-painter/CS/DXApplication9/Form1.cs#L41
InitializeRichEditControl();
ribbonControl.SelectedPage = homeRibbonPage1;
string path = @"DemoDoc.docx";
winforms-richedit-control-mail-merge/CS/MailMerge/Form1.cs#L16
InitializeComponent();
ribbonControl1.SelectedPage = mailingsRibbonPage1;
richEditControl1.LoadDocument("invitation.rtf", DocumentFormat.Rtf);
winforms-spreadsheet-use-formula-engine/CS/FormulaEngineTest/Form1.cs#L20
InitializeComponent();
ribbonControl1.SelectedPage = formulaEngineRibbonPage1;
spreadsheetControl1.Document.DocumentSettings.R1C1ReferenceStyle = true;
winforms-mvvm-expenses-app/CS/MVVMExpenses/Views/MainView.cs#L18
void ribbonControl1_Merge(object sender, DevExpress.XtraBars.Ribbon.RibbonMergeEventArgs e) {
ribbonControl1.SelectedPage = e.MergedChild.SelectedPage;
}
winforms-spreadsheet-use-cell-range-as-data-source/VB/RangeDataSource/Form1.vb#L17
spreadsheetControl1.LoadDocument("temperature.xlsx")
ribbonControl1.SelectedPage = dataRibbonPage1
End Sub
winforms-rich-edit-implement-ms-office-word-format-painter/VB/DXApplication9/Form1.vb#L40
InitializeRichEditControl()
ribbonControl.SelectedPage = homeRibbonPage1
Dim path As String = "DemoDoc.docx"
winforms-richedit-control-mail-merge/VB/MailMerge/Form1.vb#L14
InitializeComponent()
ribbonControl1.SelectedPage = mailingsRibbonPage1
richEditControl1.LoadDocument("invitation.rtf", DocumentFormat.Rtf)
winforms-spreadsheet-use-formula-engine/VB/FormulaEngineTest/Form1.vb#L19
InitializeComponent()
ribbonControl1.SelectedPage = formulaEngineRibbonPage1
spreadsheetControl1.Document.DocumentSettings.R1C1ReferenceStyle = True
winforms-mvvm-expenses-app/VB/MVVMExpenses/Views/MainView.vb#L21
Private Sub ribbonControl1_Merge(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Ribbon.RibbonMergeEventArgs)
ribbonControl1.SelectedPage = e.MergedChild.SelectedPage
End Sub
See Also