Home › Forums › WinForms controls › Xceed Grid for WinForms › Extend Right Column › Reply To: Extend Right Column
Hello!
I asked the same question and got this sample code from Xceed.
Hope it helps you.
//Subscribe on these events in the Form_Load() section
foreach(Xceed.Grid.Column c in gridControl1.Columns)
{
c.WidthChanged += new EventHandler(this.Column_WidthChanged);
c.VisibleIndexChanged += new EventHandler(this.Column_VisibleIndexChanged);
}
//Add these event methods.
private void Column_WidthChanged(object sender, EventArgs e)
{
ResizeLastColumn();
}
private void Column_VisibleIndexChanged(object sender, EventArgs e)
{
ResizeLastColumn();
}
//Add this method.
private void ResizeLastColumn()
{
int spaceLeft = gridControl1.DisplayRectangle.Width – gridControl1.RowSelectorPane.Width;
for(int cpt = 0; cpt < gridControl1.Columns.Count – 1; cpt ++)
{
spaceLeft -= gridControl1.Columns.GetColumnAtVisibleIndex(cpt).Width;
}
gridControl1.Columns.GetColumnAtVisibleIndex(2).Width = spaceLeft;
}
Imported from legacy forums. Posted by Benny (had 434 views)