We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Achieving similar behaviour to windows data grid

Thread ID:





99683 Jun 4,2011 06:51 PM UTC Jun 14,2011 03:45 AM UTC WinForms 3
Tags: GridControl
Johnathan Tunnicliffe
Asked On June 4, 2011 06:51 PM UTC

Hi Syncfusion Support,

Say for example I have a grid with two columns of width 100px. In a windows data grid if my grid was 300px wide then we automatically get an extra column that's unsortable and unmovable as the last column to fill in the gap.

With the syncfusion grid there is just a blank space the same colour as my grid background. Is it possible to easily achieve this default windows behaviour?

Thanks very much,

Jisha Joy [Syncfusion]
Replied On June 7, 2011 12:13 PM UTC

Hi John,

You could achieve the desired behavior by handling the TableControl.SizeChanged and QueryColWidth event. See the code:

int indentCols;
int parentIndentCols;

private void TableModel_QueryColWidth(object sender, GridRowColSizeEventArgs e)
GridTableModel gridModel = sender as GridTableModel;
GridTableControl grid = (GridTableControl)gridModel.ActiveGridView;

if (gridModel != null && grid != null)
int availableArea;
int VSBarSize = 0;
if (VScrollVisible)
VSBarSize = SystemInformation.VerticalScrollBarWidth;

indentCols = (gridModel.GetColumnIndentCount()) * grid.GroupingControl.TableOptions.IndentWidth;

if (e.Index > gridModel.Cols.HeaderCount + gridModel.GetColumnIndentCount() - 1)
parentIndentCols = VScrollVisible ? indentCols : indentCols - SystemInformation.VerticalScrollBarWidth;
availableArea = grid.GroupingControl.ClientSize.Width - indentCols - VSBarSize;
e.Size = (int)availableArea / (grid.TableDescriptor.VisibleColumns.Count);
e.Handled = true;


private bool VScrollVisible = false;
private void TableControl_SizeChanged(object sender, EventArgs e)
VScrollVisible = this.gridGroupingControl1.TableControl.VScroll;
GridTableControl tableControl = sender as GridTableControl;

Sample for your reference,


Please let me know if this helps.


Johnathan Tunnicliffe
Replied On June 7, 2011 02:56 PM UTC

Whilst that's ok, it doesn't really mimic what windows does. Windows introduces a new column that's unmovable and unsortable. When the normal columns take up the entire space this extra column doesn't exist. When the normal columns are bigger than the viewable area then we can scroll as normal and the extra column doesn't appear. When the total width of columns in view is smaller than the viewable area this extra column is there and takes up the remaining space.

Jisha Joy [Syncfusion]
Replied On June 14, 2011 03:45 AM UTC

Hi Johnathan,

Can you please provide us a sample showing the issue?. So that we could analyze it further.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon