Version

Key Property (UltraGridColumn)

Returns or sets a value that uniquely identifies an object in a collection.
Syntax
'Declaration
 
Public Overrides Property Key As String
public override string Key {get; set;}
Remarks

The Key property is a unique, user-defined object identification string that can be used interchangeably with the Index of an object when accessing it through code. If you attempt to assign a value to the Key property is not unique in the collection, an error will occur.

The value of the Index property of an object can change when objects in the collection are reordered, such as when you add or remove objects. If you expect the Index property to change dynamically, refer to objects in a collection using the Key property. In addition, you can use the Key property to make your program "self-documenting" by assigning meaningful names to the objects in a collection.

You can set the Key property when you use the Add method to add an object to a collection. In some instances, the Key property of an object may be blank if that object does not appear in a collection.

Also, note that the uniqueness of keys is only enforced when the Key property is set to a value. If a collection supports objects with blank keys, that collection may contain multiple objects that whose Key property is empty. In that case, you must use Index property to differentiate between the objects that have blank keys.

Example
Following code prints out some information about the active cell.

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

   Private Sub Button32_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button32.Click

       ' Check if there is an active cell.
       If Not Me.ultraGrid1.ActiveCell Is Nothing Then
           ' Print out the the column key and the row index of the active cell.
           Debug.WriteLine("ActiveCell's column = " & Me.ultraGrid1.ActiveCell.Column.Key & ", Row Index = " & Me.ultraGrid1.ActiveCell.Row.Index.ToString())
       Else
           Debug.WriteLine("There is no active cell.")
       End If

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

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

	// Check if there is an active cell.
	if ( this.ultraGrid1.ActiveCell != null )
	{
		// Print out the the column key and the row index of the active cell.
		Debug.WriteLine( "ActiveCell's column = " + this.ultraGrid1.ActiveCell.Column.Key + ", Row Index = " + this.ultraGrid1.ActiveCell.Row.Index.ToString( ) );
	}
	else
	{
		Debug.WriteLine( "There is no active cell." );
	}

}
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