Infragistics UltraGrid Right-click Selection in Grid?

A

Ayron

Ok. I give. How can you select a row in the UltraGrid upon mouse
right-click?

Thx.

-ak
 
A

Andy

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

Thx, Andy! One would think that this functionality would either exist
by default or would be a bit easier to employ. :)

-ak
 
A

Ayron

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top