Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics
Private Sub Button56_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button56.Click
' Get the cell you want to get the location of.
Dim cell As UltraGridCell = Me.UltraGrid1.ActiveCell
If Not Nothing Is cell Then
' If there are multiple scroll regions, then we have to specify which scroll region to
' get the ui element in. A cell could be visible in multiple places if you had split the
' grid in two or more scroll regions. Intersection of ActiveRowScrollRegion and the
' ActiveColScrollRegion make up the active scroll region which is where the edit control
' would be positioned by the UltraGrid for editing the cell's contents if the cell were
' in edit mode.
Dim rsr As RowScrollRegion = Me.ultraGrid1.ActiveRowScrollRegion
Dim csr As ColScrollRegion = Me.ultraGrid1.ActiveColScrollRegion
Dim contexts As Object() = New Object() {rsr, csr, cell}
' Get the ui element associated with the cell.
Dim cellElem As CellUIElement = DirectCast(Me.ultraGrid1.DisplayLayout.UIElement.GetDescendant(GetType(CellUIElement), contexts), CellUIElement)
If Not Nothing Is cellElem Then
' Write out the cell's location in the UltraGrid.
Dim cellBounds As Rectangle = cellElem.Rect
Debug.WriteLine("Cell's bounds in the UltraGrid are " & cellBounds.ToString())
Else
' If there is no ui element associated with the cell, then the cell is not visible.
Debug.WriteLine("Cell is not visible in the UltraGrid.")
End If
Else
Debug.WriteLine("There is no active cell.")
End If
End Sub