Well, if you are getting a UIElement, then it should just be a matter of calling GetContext to get the column. What kind of UIElement are you getting? What is it's type?
It's possible that you might need to call GetContext and get a ColumnHeader, rather than an UltraGridColumn. Perhaps the header element only has a context of it's header and not the column itself. If you can get a ColumnHeader, you can get the column via the Column property.
Hi Mike,
Yes, I do have UIElement value after ElementFromPoint conversion. I think the reason I got them not recognized at runtime might be out-of-memory or something. Even that I still have not figured out how to make the custom swapping of columns in grid working. I am wondering if you can provide with some code sample or guildlines or some articles. I have looked for them in the Forums and KB and found some, but still not work for me. Thanks.
I'm not sure why it isn't working. Why not step through it and look at the point you are getting before and after the PointToClient call and see if the numbers seem reasonable.
Are you getting a UIElement at all from ElementFromPoint?
Thanks for the reply, I tried adding the coords convertion before calling ElementFromPoint, but it still does not work. I tried to get different grid elements, but all of them were not recognized at runtime, didn't know why. Please help. Here is the code and the debuggint output:
private void ultraGrid1_DragDrop( object sender, DragEventArgs e )
Point pt = this.ultraGrid1.PointToClient( new Point( e.X, e.Y ) );
UIElement uiEl = this.ultraGrid1.DisplayLayout.UIElement.ElementFromPoint( pt );
UltraGridColumn col = uiEl.GetContext( typeof( UltraGridColumn ) ) as UltraGridColumn;
=====================
Debug output:
The X and Y coords in the DragDrop events are not in control coords, they are in screen coords. So you just need to call grid.PointToClient to convert them to grid coords before you call ElementFromPoint.