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

How do you enable users to move columns in virtual grid?

Thread ID:





14683 Jun 2,2004 10:52 AM UTC Jun 2,2004 02:01 PM UTC WinForms 3
Tags: GridControl
Administrator [Syncfusion]
Asked On June 2, 2004 10:52 AM UTC

How can you enable a user to drag one column header to another place, thereby causing the columns to be reordered?

Administrator [Syncfusion]
Replied On June 2, 2004 01:18 PM UTC

You can get the UI working just by setting the grid.AllowDragSelectedCols = true. But this will not actually change the columns. To manage this, you need to maintain a correspondence between the initial col positions and any moved col positions. You could do them in several ways, One would be to add an array of ints that you initialize 1 through the number of columns. Then when a column is moved, you move this elements of this int array. Also, anytime you access your external datasource, you use this index array to manage the proper corespondance. That''s the idea. Now you could also add sort of a hidden row at the top of the grid that you use as this index array, and you initialize it to start as 1 to number of columns. The advantage is that the the grid itself will take care of moving these values. Here is the modified VirtGrid tutorial that uses this technique. It adds (and hides) a row at the top of the grid, The SaveCellInfo and QueryCellInfo have been modified to use this row value as col index into the external data source. (Instead of adding a hidden row, if you are OK with storing values in the column headers, you could use the ColStyles.Tag to hold the original index for each column.)

Administrator [Syncfusion]
Replied On June 2, 2004 01:35 PM UTC

I set that property but weirdly when I select a column header it does not actually select the entire column. How do you (re)enable that functionality?

Administrator [Syncfusion]
Replied On June 2, 2004 02:01 PM UTC

Check the grid.AllowSelections property. Make sure this property includes columns. One other point is that if you have ListBoxSelectionMode set to anything other than None, then you will not be able to select a column since listboxselections require only row selections. If you want to move columns in ListBoxSelection mode, then you might try the technique shown in the sample in this forum thread. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9676 It allows you to just mousedown on a column header and drag it to move the columns (by passing the default column moving UI that requires you to select the column first.)


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

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon