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.
Unfortunately, activation email could not send to your email. Please try again.

Achieving similar behaviour to windows data grid

Thread ID:

Created:

Updated:

Platform:

Replies:

99683 Jun 4,2011 02:51 PM Jun 13,2011 11:45 PM Windows Forms 3
loading
Tags: GridControl
Johnathan Tunnicliffe
Asked On June 4, 2011 02:51 PM

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,
John


Jisha Joy [Syncfusion]
Replied On June 7, 2011 08:13 AM

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;
tableControl.Invalidate();
}


Sample for your reference,

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC-1100757244.zip


Please let me know if this helps.

Regards,
Jisha


Johnathan Tunnicliffe
Replied On June 7, 2011 10:56 AM

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 13, 2011 11:45 PM

Hi Johnathan,

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

Regards,
Jisha


CONFIRMATION

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.

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.

;