New to Telerik UI for WPF? Download free 30-day trial

Get the Row or Column Index of the Mouse Position

In a scenario when the row/column index for the mouse position is needed, the GetRowIndexAtMousePosition and GetColumnIndexAtMousePosition methods come in handy. In order to return the needed index, they accept a parameter of type CanvasInputBorder. This Border is used internally by RadVirtualGrid to enable mouse interaction with the control. For example, if the row and column indexes for the MouseRightButtonDown event of RadVirtualGrid are needed, its event handler would be similar to the following one.

Example 1: Getting the Row and Column Index on MouseRightButtonDown event

private void VirtualGrid_MouseRightButtonDown(object sender, MouseButtonEventArgs e) 
        var border = e.OriginalSource as Telerik.Windows.Controls.VirtualGrid.CanvasInputBorder; 
        var columnIndex = this.VirtualGrid.GetColumnIndexAtMousePosition(border); 
        var rowIndex = this.VirtualGrid.GetRowIndexAtMousePosition(border); 

See Also

In this article
Not finding the help you need? Improve this article