Hello,
We are using an UtraGrid to initiate drag-drop operations. Multiple records should be drag-dropped, so the ExtendedAutoDrag works very well. However, we expected that holding down the mouse on the rowselector and consecutively holding down the mouse while hovering other rows would select the other rows. The observed behavior is the initiation of the drag-drop operation on the row where we clicked and held down on the rowselector.
Is there a way to change this behavior? The rowselector is clearly intended for selecting rows. This way we could allow an user to select multiple rows with the mouse while also allowing the user to drag-drop these rows.
Thank you for your time,
Anne
Hello Anne,
I've investigated into this and not found this to be possible yet. I do have a few more strategies I'd like to try out without dismissing it though, and I will continue looking at it and update you on my progress no later than close of business tomorrow.
Thank you for looking into it, John. No rush though, this is not a show stopper for us.
Fantastic, I did not know that the SelectionDrag event subscription would change the behaviour of the selection type.
Your solution almost fits perfectly. Our specific case could run into an issue since a selectiondrag event subscription could theoretically be done during the hover on the rowselector.
I've modified your code a bit and put the following lines in an override of the Ultragrid. It works perfect now. Thank you!
protected override void OnMouseEnterElement(UIElementEventArgs e) { if (e.Element is RowSelectorUIElement) { switch (this.DisplayLayout.Override.SelectTypeRow) { case SelectType.ExtendedAutoDrag: this.DisplayLayout.Override.SelectTypeRow = SelectType.Extended; break; case SelectType.SingleAutoDrag: this.DisplayLayout.Override.SelectTypeRow = SelectType.Single; break; default: break; } } base.OnMouseEnterElement(e); } protected override void OnMouseLeaveElement(UIElementEventArgs e) { if (e.Element is RowSelectorUIElement) { switch (this.DisplayLayout.Override.SelectTypeRow) { case SelectType.Extended: this.DisplayLayout.Override.SelectTypeRow = SelectType.ExtendedAutoDrag; break; case SelectType.Single: this.DisplayLayout.Override.SelectTypeRow = SelectType.SingleAutoDrag; break; default: break; } } base.OnMouseLeaveElement(e); }
Hello Anne, The best way I found to suppress the dragging when using the row selector is to use the MouseEnter/LeaveElement events to (un)subscribe the SelectionDrag handler. My code looked like:
private void UltraGrid1_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e) { if (e.Element is RowSelectorUIElement) { ultraGrid1.SelectionDrag -= UltraGrid1_SelectionDrag; } } private void UltraGrid1_MouseLeaveElement(object sender, Infragistics.Win.UIElementEventArgs e) { if (e.Element is RowSelectorUIElement) { ultraGrid1.SelectionDrag += UltraGrid1_SelectionDrag; } }
This allowed me to select rows on the row selector, but drag them by dragging over the cells themselves. Please note that in order to successfully do the latter I had to set CellClickAction to RowSelect so that my row selection remained when I clicked into the cells.
Please let me know if I can further assist you.