Description:
How do I change the order of the detail tabs?
Answer:
Actually, it is possible to reorder detail tabs. Just there isn't any editor to do this visually. Please let us explain this possibility using the Master-Detail demo example:
- Open the GridMainDemo project, build it and open the MasterDetail module.
- You may see that the Grid has several levels and Views defined.
The hierarchical structure of the levels is stored in the LevelTree property. You can change the order of the defined levels by editing the InitializeComponent method (the Designer generated code).
Look for the LevelTree code. You will find a line which adds two nodes. They correspond to the SuppliersProducts and SuppliersCategoryProducts
Reorder the nodes in the AddRange method:
C#this.gridControl1.LevelTree.Nodes.AddRange(new DevExpress.XtraGrid.GridLevelNode[] {
gridLevelNode3,
gridLevelNode1});
Rebuild the project and open the Designer. You will see that the levels have reflected your change.
3. Finally, you must set the GridControl.ShowOnlyPredefinedDetails property to true to prevent the Grid from using more levels than are explicitly defined. Also, enabling this option cancels re-building the level tree according to the data source schema at runtime. This way, changes made in the designer file will be reflected at runtime.
Here is the resulting view of the Grid at runtime:
NOTE: Be careful editing the Designer Generated code. You can break the components on your form, so that when the form is saved next time, the controls are removed and cannot be restored.
Is this still the recommended way to change the order of tabs in a details view? It seems inefficient, and this answer is ten years old.
Hello Jon,
Yes, currently, we recommend you use this approach to reorder detail views at design time. Please clarify why this approach does not meet your requirements.
I hope to hear from you soon.
You should put more emphasis on the fact that without setting GridControl.ShowOnlyPredefinedDetails = true the whole workaround won't work.
It's not only there to prevent more levels to appear but also to disable auto generation of levels and their order in the tree.
Hello,
I've added additional info to the third paragraph in this article. Thank you for your observation.
My refresh tab script is not functioning anymore after i set ShowOnlyPredefinedDetails to true.
My tabs are still mixed up =(
For index = 0 To Form.grdViewMain.DataRowCount If Form.grdViewMain.GetMasterRowExpanded(index) Then Dim openDetailView = Form.grdViewMain.GetVisibleDetailView(index) If Not openDetailView Is Nothing Then Dim tabControl As ViewTab = DirectCast(GetType(BaseView).GetProperty("TabControl", Reflection.BindingFlags.Instance OrElse Reflection.BindingFlags.NonPublic).GetValue(openDetailView), ViewTab) tabControl.Populate() End If End If Next
Hello Christophe,
Let's discuss this case separately in a ticket I've created from your behalf - Grid - Reordering detail tabs in the master-detail view stops working after enabling ShowOnlyPredefinedDetails. Thank you for your cooperation in advance.
Hello support team,
Is there a way to do the tab ordering programatically? I don't use the designer to set up my views.
Thank you.
Hello,
I've created a separate ticket on your behalf (T604813: How to re-order detail views). It has been placed in our processing queue and will be answered shortly.