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. Image for the cookie policy date

Sorting and Drag&Drop columns

Hi, I am using the GridControlSort example. I uncomment the line this.gridControl1.AllowSelection = GridSelectionFlags.Any & ~GridSelectionFlags.Column; in the Form1_Load method for column drag & drop purpose. Sorting doesn''t work all the time when I click on the column header. The column re-ording cursor shows up as well. My second problem is I want list mode selection. If I have this on, than I can select a column and hence can not re-order columns.

6 Replies

AD Administrator Syncfusion Team June 24, 2004 04:04 PM UTC

If you want to move columns using the default grid support for moving columns, then the columns have to be selectable. So you will have to add the columns flag back to the AllowSelections property to do this. If you do this, you could use a double click to sort, and a single click to select the column for moving. In this case, to get ListBoxSelectionMode to work with column moving, you will have to explicitly select the column when you click on it. (The reason is that listboxbox mode tells teh grid ot only select rows. SO, if you want a column selected so you can move it, you have to explicitly select it.) private void gridControl1_CellClick(object sender, GridCellClickEventArgs e) { //use this code to try to handle column selections with ListBoxSelectionMode set if(e.ColIndex > 0 && e.RowIndex == 0) { this.gridControl1.Selections.Add(GridRangeInfo.Col(e.ColIndex)); } } Now if you want to drag a column without first selecting it, check out this forum thread. It contains a sample. (You still will have to decide when a click is for moving the column or for sorting if you want to try to sort on a single click). http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9676

AD Administrator Syncfusion Team June 24, 2004 06:37 PM UTC

thank you.

AD Administrator Syncfusion Team June 25, 2004 03:15 PM UTC

I try out the sample in the other thread, column resizing doesn''t work too well. When resizing the column, it treats it as column re-ordering.

AD Administrator Syncfusion Team June 25, 2004 03:38 PM UTC

I think you can handle this problem by adding this if-code around the current ''big'' if in the OnMouseMove code in the derived grid. if(this.Cursor.Equals(Cursors.Arrow)) { //existing if statement } base.OnMouseMove(e);

AD Administrator Syncfusion Team June 25, 2004 03:48 PM UTC

I am using a GridControl in my code, but the sample is a GridDataBoundGrid, when I click on the header, the cursor is not an arrow. How do I make the cursor an arrow even if I click on the column for sorting?

AD Administrator Syncfusion Team June 25, 2004 08:31 PM UTC

Here is the sample modified to use a GridControl. If you want to catch the click on a header, you can return from the MouseUp without calling the base class if you have moved a column. This will make the CellClick only fire when you do not move a column. The sample seems to size columns, move column and catch a single click in the CellClick event for me. Forum_DragColOnFirstClick_3704.zip

Live Chat Icon For mobile
Up arrow icon