Skip to main content

TablePanel.Rows Property

Gets a collection of rows.

Namespace: DevExpress.Utils.Layout

Assembly: DevExpress.Utils.v25.1.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

[DXCategory("Layout")]
public TablePanelRowCollection Rows { get; }

Property Value

Type Description
DevExpress.Utils.Layout.TablePanelRowCollection

A collection of TablePanelRow objects.

Remarks

Use the TablePanel.Rows property to access rows in the TablePanel. You can enumerate, add, remove, or modify rows.

The following code snippet does the following:

  • Adds rows and columns to a TablePanel
  • Displays a button in the top-left cell.

WinForms TablePanel, DevExpress

using DevExpress.Utils.Layout;
using DevExpress.XtraEditors;
using System.Windows.Forms;

namespace DXTablePanelDemo {
    public partial class Form1 : XtraForm
    {
        TablePanel tablePanel1;
        LabelControl labelControl1;
        public Form1()
        {
            InitializeComponent();

            // Create and configure a TablePanel.
            tablePanel1 = new TablePanel()
            {
                Name = "tablePanel1",
                Dock = DockStyle.Fill,
                ShowGrid = DevExpress.Utils.DefaultBoolean.True
            };

            // Add 3 columns.
            tablePanel1.Columns.Add(new TablePanelColumn(TablePanelEntityStyle.AutoSize, 0));   // Adjusts the column width to cell content. 
            tablePanel1.Columns.Add(new TablePanelColumn(TablePanelEntityStyle.Relative, 1));   // Takes 1 share of the remaining space.
            tablePanel1.Columns.Add(new TablePanelColumn(TablePanelEntityStyle.Relative, 2));   // Takes 2 shares of the remaining space.

            // Add 3 rows.
            tablePanel1.Rows.Add(new TablePanelRow(TablePanelEntityStyle.AutoSize, 0)); // Adjusts the row height to cell content.
            tablePanel1.Rows.Add(new TablePanelRow(TablePanelEntityStyle.Relative, 1)); // Takes 1 share of the remaining height.
            tablePanel1.Rows.Add(new TablePanelRow(TablePanelEntityStyle.Absolute, 60)); // Fixed height = 60 pixels.

            // Access the third row and modify its height.
            tablePanel1.Rows[0].Height = 80;

            labelControl1 = new LabelControl() { Text = "Cell [0; 0]" };
            tablePanel1.Controls.Add(labelControl1);

            // Display the labelControl1 in the top left cell.
            tablePanel1.SetCell(labelControl1, 0, 0);

            Controls.Add(tablePanel1);
        }
    }
}
See Also