Posted 29 July 2018, 5:23 pm EST
Hello,
First of all, apologies for the time taken in responding to you.
Reg, the requirement, if you set Width of all columns to * then you should be get a behavior pretty close to the one shown in your video. The difference would be: When resizing a column, if all remaining columns have achieved their MinWidth (showing …) and then if the user tries to further extend the column, C1DataGrid would allow that whereas, in your video, it looks like extending beyond it is not possible/allowed. This is the design behavior of C1DataGrid.
However, if you wish to prevent that too, you need to manually handle the ColumnResizing event and calculate the width for all columns then compare the values and accordingly set MaxWidth for that column, as follows:
private void _grid_ColumnResizing(object sender, C1.WPF.DataGrid.DataGridColumnEventArgs e)
{
totalWidth = 0;
foreach (C1.WPF.DataGrid.DataGridColumn col in _grid.Columns)
{
if (col != e.Column)
{
totalWidth += col.ActualWidth;
col.MaxWidth = Double.MaxValue;
}
}
if (_grid.ActualWidth <= (totalWidth + e.Column.ActualWidth +25 ))
e.Column.MaxWidth = e.Column.ActualWidth;
else
e.Column.MaxWidth = Double.MaxValue;
}
```I also attached a demo application for this purpose.
Regards,
Ruchir
[zip filename="ColumnWidth_C1DataGrid.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-069462b9-3db6-4cad-b2de-0da0e20f6505.zip[/zip]