We are implementing dragging and dropping rows. We would like to display something like a red line to the insertion point (drop location)? Is this already supported by UltraGrid or has to be custom coded?
Hi,
Here's some code that will get you a Bitmap of the row, or any UIElement, really. This will only work if the element exists, of course, which means the row has to be visible on the screen. I don't think that will be a problem for you, considering you are using it for drag and drop, but if the user is selecting multiple rows and dragging them, some of them might be off-screen and so they will not have a UIElement.
Also... only the cells that are visible will have UIElements, so some parts of the row which are not visible on-screen might be appear empty.
#region GetRowImage private Image GetRowImage(UltraGridRow row) { return GetElementImage(row.GetUIElement()); } #endregion // GetRowImage #region GetElementImage private Bitmap GetElementImage( UIElement element ) { if (element == null) return null; Rectangle rect = element.Rect; Bitmap bitmap = null; Graphics g = null; try { // create a bitmap to render into bitmap = new Bitmap(rect.Width, rect.Height); // create a graphics object to wrap the bitmap g = Graphics.FromImage(bitmap); // offset based on the location of the element within // the control g.TranslateTransform(-rect.X, -rect.Y, System.Drawing.Drawing2D.MatrixOrder.Prepend); // have the element draw into the graphics object element.Draw( g, rect, false, true ); } finally { if (g != null) g.Dispose(); } return bitmap; } #endregion //GetElementImage
The link should work.
One more thing, is there a way to grab an image of the row being dragged to be used for the drag cursor?
Hello,
I believe that this topic has already been discussed in the following forum thread: http://ko.infragistics.com/community/forums/p/25303/331191.aspx.
Please do not hesitate to contact me if you need any additional assistance.