Version

UIElement Property (UltraGridLayout)

The main UIElement for the grid (read-only)
Syntax
'Declaration
 
Public ReadOnly Property UIElement As UltraGridUIElement
public UltraGridUIElement UIElement {get;}
Example
The following sample code illustrates how UIElements can be used. It finds out what element the user clicked on and outputs some context information about the element.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub ultraGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ultraGrid1.Click

       Dim mainElement As UIElement
       Dim element As UIElement
       Dim screenPoint As Point
       Dim clientPoint As Point
       Dim row As UltraGridRow
       Dim cell As UltraGridCell

       ' Get the control's main element
       mainElement = Me.ultraGrid1.DisplayLayout.UIElement

       ' Convert the current mouse position to a point
       ' in client coordinates of the control.
       screenPoint = Control.MousePosition
       clientPoint = Me.ultraGrid1.PointToClient(screenPoint)

       ' Get the element at that point
       element = mainElement.ElementFromPoint(clientPoint)

       If element Is Nothing Then Return

       Debug.WriteLine("Clicked on an " + element.GetType().ToString())
       Debug.Indent()

       ' Get the row that contains this element.
       row = element.GetContext(GetType(UltraGridRow))

       If Not row Is Nothing Then

           Debug.WriteLine("in row: " + row.Index.ToString())

           ' Get the cell that contains this element.
           cell = element.GetContext(GetType(UltraGridCell))

           If Not cell Is Nothing Then
               Debug.WriteLine("in column: " + cell.Column.Key)
               Debug.WriteLine("cell text: " + cell.Text)
           End If
       End If

       ' Walk up the parent element chain and write out a line 
       ' for each parent element.
       While Not element.Parent Is Nothing
           element = element.Parent
           Debug.WriteLine("is a child of an " + element.GetType().ToString())
           Debug.Indent()
       End While

       ' reset the indent level
       Debug.IndentLevel = 0

   End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;

private void ultraGrid1_Click(object sender, System.EventArgs e)
{

	UIElement mainElement;
	UIElement element;
	Point screenPoint;
	Point clientPoint;
	UltraGridRow row;
	UltraGridCell cell;

	// Get the control's main element
	mainElement = this.ultraGrid1.DisplayLayout.UIElement;
 
	// Convert the current mouse position to a point
	// in client coordinates of the control.
	screenPoint = Control.MousePosition;
	clientPoint = this.ultraGrid1.PointToClient( screenPoint );

	// Get the element at that point
	element = mainElement.ElementFromPoint( clientPoint );

	if ( element == null )
		return;

	Debug.WriteLine( "Clicked on an " + element.GetType().ToString() );
	Debug.Indent();

	// Get the row that contains this element.
	row = element.GetContext( typeof( UltraGridRow ) )
					as UltraGridRow;
	
	if ( row != null )
	{
		Debug.WriteLine( "in row: " + row.Index.ToString() );

		// Get the cell that contains this element.
		cell = element.GetContext( typeof( UltraGridCell ) )
						as UltraGridCell;
		if ( cell != null )
		{
			Debug.WriteLine( "in column: " + cell.Column.Key );
			Debug.WriteLine( "cell text: " + cell.Text );
		}
	}

	// Walk up the parent element chain and write out a line 
	// for each parent element.
	while (element.Parent != null )
	{
		element = element.Parent;
		Debug.WriteLine("is a child of an " + element.GetType().ToString());
		Debug.Indent();
	}

	// reset the indent level
	Debug.IndentLevel = 0;
		
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also