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

Single-click sort and column drag and drop in GDBG

I assume you will drag the column without first selecting it, is that correct? The default support for column moving within the grid is to first select a column (or several columns), and then mousedown and drag them. But if you want a single click to sort, then you would not have a single click available to select a single column so it would later be draggable. So, to get this behavior, I think you have at least two options to try. One is to derive your own custom mouse controller, and the other is to catch the MouseDown on the header, and track it to determine whether it is part of a sort click or a column move. If it is a column move, then you would have to manage the UI at this point to complete the drag to a new column. If you get stuck and need help doing it, post again or submit a Direct Trac support incident, and maybe we can work up a little sample.

11 Replies

GG Gene Gorokhovsky January 6, 2004 05:12 PM UTC

We use GDBG v 1.6.1.6. One of the application requirements is to allow both single-click sorting and column drag-and-drop moving similarly to Microsoft's explorer-like listview. How do we implement this behavior? Thanks, Gene Gorokhovsky


GG Gene Gorokhovsky January 7, 2004 12:51 PM UTC

> I assume you will drag the column without first selecting it, is that correct? yes. > So, to get this behavior, I think you have at least two options to try. One is to derive your own custom mouse controller, and the other is to catch the MouseDown on the header > If you get stuck and need help doing it, post again or submit a Direct Trac support incident, and maybe we can work up a little sample. I took a look at the grid's internal MouseControllers and neither of the suggested ways look sufficiently straightforward for me to try it on my own, so an example would defintely be much appreciated. The "grouping preview" seems to have the behavior closest to what is required, but source code for it ios not available. So, please, consider this post official "request for example". I can open a DirectTrac if will give the request higher priority. Thanks, Gene


AD Administrator Syncfusion Team January 7, 2004 08:15 PM UTC

The GridGroupingControl code with its draggable header cells is available in the 2.0.1.0 beta release. Here is one implementation that uses a derived grid, handling the mouse events to manage the move. It only uses cursors to give feedback during the move. You could do something fancier, dragging a transparent bitmap or something. There is a static method in the grid, GridUtil.DrawDragRectHelper, that you can use to implement better feedback.


AD Administrator Syncfusion Team January 8, 2004 05:23 PM UTC

They are two different controls. If you need to use features in the GridGroupingControl, you will have to swap out your GridDataBoundGrid''s with GridGroupingControls, and there will be coding changes required. The GridDataBoundGrid is still a supported control, and may be the grid of choice depending upon the exact functionality you need.


GG Gene Gorokhovsky January 8, 2004 05:36 PM UTC

Terrific! This is exactly what I needed. Does GridGroupingControl obsolete GridDataBoundGrid or does it augment it? Gene > The GridGroupingControl code with its draggable header cells is available in the 2.0.1.0 beta release. > > Here is one implementation that uses a derived grid, handling the mouse events to manage the move. It only uses cursors to give feedback during the move. You could do something fancier, dragging a transparent bitmap or something. There is a static method in the grid, GridUtil.DrawDragRectHelper, that you can use to implement better feedback. > > >


GG Gene Gorokhovsky January 8, 2004 05:36 PM UTC

Terrific! This is exactly what I needed. Does GridGroupingControl obsolete GridDataBoundGrid or does it augment it? Gene > The GridGroupingControl code with its draggable header cells is available in the 2.0.1.0 beta release. > > Here is one implementation that uses a derived grid, handling the mouse events to manage the move. It only uses cursors to give feedback during the move. You could do something fancier, dragging a transparent bitmap or something. There is a static method in the grid, GridUtil.DrawDragRectHelper, that you can use to implement better feedback. > > >


GG Gene Gorokhovsky January 8, 2004 05:47 PM UTC

> You could do something fancier, dragging a transparent bitmap or something. There is a static method in the grid, GridUtil.DrawDragRectHelper, that you can use to implement better feedback. DrawDragRectHelper is in GridPaint, and it is an internal class, so even public statics are not available outside the assembly, but cut and paste does wonders! Gene


ST Suraj Tamboli September 20, 2004 05:19 PM UTC

In this sample there is bug. When you resize a column it moves the column too. Do you have any fix for this ? Thanks, >The GridGroupingControl code with its draggable header cells is available in the 2.0.1.0 beta release. > >Here is one implementation that uses a derived grid, handling the mouse events to manage the move. It only uses cursors to give feedback during the move. You could do something fancier, dragging a transparent bitmap or something. There is a static method in the grid, GridUtil.DrawDragRectHelper, that you can use to implement better feedback. > > >


AD Administrator Syncfusion Team September 20, 2004 06:06 PM UTC

Hi Suraj, The following changes prevent that from happening: protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { int ht = this.HitTest(new Point(e.X, e.Y)); if (ht == GridHitTestContext.Header) this.mouseDownPt = new Point(e.X, e.Y); else this.mouseDownPt = Point.Empty; base.OnMouseDown(e); } and in OnMouseMove the first line: if(e.Button == MouseButtons.Left && !this.mouseDownPt.IsEmpty) Stefan


MO mowmow March 16, 2005 04:21 PM UTC

I am using a GridControl. The Drag and drop of the columns with a single click works fine, but I want to be able to show that a column is actually dragged (Something similar to way column are dragged on the GridGroupingControl with the column header transparent attached to the mouse). As I understood, GridUtil.DrawDragRectHelper would allow to do something like that, but, it is not documented and I have not been able to figure how it could be used... Ams >> You could do something fancier, dragging a transparent bitmap or something. There is a static method in the grid, GridUtil.DrawDragRectHelper, that you can use to implement better feedback. > > > >DrawDragRectHelper is in GridPaint, and it is an internal class, so even public statics are not available outside the assembly, but cut and paste does wonders! > >Gene > > > >


AD Administrator Syncfusion Team March 16, 2005 11:48 PM UTC

Here is a link to a little sample using the drag helper class. http://www.syncfusion.com/Support/user/uploads/forum_DragColumn_dcac527f.zip

Loader.
Up arrow icon