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

Move a column in a DataGrid with a nested relation

Thread ID:

Created:

Updated:

Platform:

Replies:

25619 Mar 2,2005 12:48 PM UTC Mar 11,2005 05:05 PM UTC WinForms 4
loading
Tags: GridControl
seb
Asked On March 2, 2005 12:48 PM UTC

I am trying to move columns in a DataGrid using Model.Cols.MoveRange methods It works fine in most cases but if I have a nested relation then it doesn''t work anymore... I made a try with the sample: ExpandGrid. I simply added a button (by pressing the button I just want to move column 3 to column 1): private void button1_Click(object sender, System.EventArgs e) { System.Console.WriteLine( gridDataBoundGrid1.Binder.InternalColumns.Count ); gridDataBoundGrid1.Model.Cols.MoveRange(3,1); } By doing that, I change the Binder.InternalColums and after one click, one column is missing!!! If I change the code to (by pressing the button I want to move column 1 to column 3): private void button1_Click(object sender, System.EventArgs e) { System.Console.WriteLine( gridDataBoundGrid1.Binder.InternalColumns.Count ); gridDataBoundGrid1.Model.Cols.MoveRange(1,3); } Now, I get an exception. System.ArgumentOutOfRangeException: L''index était hors limites. Il ne doit pas être négatif et doit être inférieur à la taille de la collection. Nom du paramètre : index at System.Collections.ArrayList.get_Item(Int32 index) at Syncfusion.Windows.Forms.Grid.GridBoundColumnsCollection.get_Item(Int32 index) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.ModelColsMoving(Object sender, GridRangeMovingEventArgs e) at Syncfusion.Windows.Forms.Grid.GridDataBoundGridModel.OnColsMoving(GridRangeMovingEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.RaiseColsMoving(GridRangeMovingEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelColOperations.RaiseMoving(GridRangeMovingEventArgs e) catched at Syncfusion.Windows.Forms.Grid.GridModelColOperations.RaiseMoving(GridRangeMovingEventArgs e) in :line 0 How can I do to move a column in a grid that contains a nested relation? Thanks in advance, Sebastien

Administrator [Syncfusion]
Replied On March 2, 2005 05:05 PM UTC

To get this to work, I think you will have to collapse all expanded rows before you move the columns. You could test this out to see if your moving code works ok as long as there are no expanded rows. If it does work, then you could freeze the painting in the grid, collapse all rows, move the columns, and then restore the expand-state of the grid, and then unfreeze the painting and then redraw the grid. Here is a link to a forum thread that discusses how to do something like this. It has a sample that saves the expand state before a sort, freezes the painting, sorts the grid, and then resets the expand state. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11104

seb
Replied On March 3, 2005 12:56 PM UTC

Thank you for your response. It was a good idea. Unfortunately, the problem occurs even if all the rows are collapsed. >To get this to work, I think you will have to collapse all expanded rows before you move the columns. You could test this out to see if your moving code works ok as long as there are no expanded rows. > >If it does work, then you could freeze the painting in the grid, collapse all rows, move the columns, and then restore the expand-state of the grid, and then unfreeze the painting and then redraw the grid. Here is a link to a forum thread that discusses how to do something like this. It has a sample that saves the expand state before a sort, freezes the painting, sorts the grid, and then resets the expand state. > >http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11104

Administrator [Syncfusion]
Replied On March 4, 2005 12:02 PM UTC

Try this.gridDataBoundGrid1.Model.Cols.MoveRange(4,2); instead of (3,1). Column 1 is the +/- column in an hierarchical grid.

seb
Replied On March 11, 2005 05:05 PM UTC

You were right and the API Grid.GridHierarchyLevel.LayoutColumns() solved the other part of my problem. Thanks Clay!

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.

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

;