A Ayron Sep 26, 2006 #1 Ok. I give. How can you select a row in the UltraGrid upon mouse right-click? Thx. -ak
A Andy Sep 26, 2006 #2 Handle the MouseDown or MouseUp event for the grid. In the handler: private void UltraGrid_MouseDown( object sender, MouseEventArgs e ) { UltraGridRow row; UltraGridRow result; UIElement element; if ( e.Button == MouseButtons.Right ) { element = UltraGrid.DisplayLayout.UIElement.ElementFromPoint( e.Location ); result = element.GetContext( typeof( UltraGridRow ) ) as UltraGridRow; if ( row != null && row.IsDataRow ) { row.Selected = true; } } }
Handle the MouseDown or MouseUp event for the grid. In the handler: private void UltraGrid_MouseDown( object sender, MouseEventArgs e ) { UltraGridRow row; UltraGridRow result; UIElement element; if ( e.Button == MouseButtons.Right ) { element = UltraGrid.DisplayLayout.UIElement.ElementFromPoint( e.Location ); result = element.GetContext( typeof( UltraGridRow ) ) as UltraGridRow; if ( row != null && row.IsDataRow ) { row.Selected = true; } } }
A Ayron Sep 26, 2006 #3 Thx, Andy! One would think that this functionality would either exist by default or would be a bit easier to employ. -ak
Thx, Andy! One would think that this functionality would either exist by default or would be a bit easier to employ. -ak
A Ayron Sep 27, 2006 #4 For others with similar issue, here's the VB translation... I use this in the MouseDown event handler... '//// begin code ////// 'if we right-click, isolate the row underneath the mouse cursor and set it as active If e.Button = Windows.Forms.MouseButtons.Right Then Dim row As Infragistics.Win.UltraWinGrid.UltraGridRow = Nothing Dim element As Infragistics.Win.UIElement = Nothing element = [yourGrid].DisplayLayout.UIElement.ElementFromPoint(e.Location) row = element.GetContext(GetType(Infragistics.Win.UltraWinGrid.UltraGridRow)) If (row IsNot Nothing) AndAlso (row.IsDataRow) Then [yourGrid].ActiveRow = row End If End If '///// end code ///// Thanks again Andy. -ak
For others with similar issue, here's the VB translation... I use this in the MouseDown event handler... '//// begin code ////// 'if we right-click, isolate the row underneath the mouse cursor and set it as active If e.Button = Windows.Forms.MouseButtons.Right Then Dim row As Infragistics.Win.UltraWinGrid.UltraGridRow = Nothing Dim element As Infragistics.Win.UIElement = Nothing element = [yourGrid].DisplayLayout.UIElement.ElementFromPoint(e.Location) row = element.GetContext(GetType(Infragistics.Win.UltraWinGrid.UltraGridRow)) If (row IsNot Nothing) AndAlso (row.IsDataRow) Then [yourGrid].ActiveRow = row End If End If '///// end code ///// Thanks again Andy. -ak