Version

DataKey Property

Gets/sets a value that is used to store a dataset key or other information.
Syntax
'Declaration
 
Public Property DataKey As Object
public object DataKey {get; set;}
Remarks

DataKey is essentially an additional Tag property of a node which can be used for storing key information for relational data. It is intended for use when the Override.ShowExpansionIndicator property of a node is set to CheckOnDisplay.

Example
The following sample code illustrates some of the information available in the BeforeExpand event.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Win.UltraWinTree

Private Sub ultraTree1_BeforeExpand(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.CancelableNodeEventArgs) Handles ultraTree1.BeforeExpand

    ' Note: In order to load node collections on demand, set
    ' the appropriate Override object's 'ShowExpansionIndicator' 
    ' property to 'CheckOnExpand'. Then in this event place 
    ' logic to add the child nodes to the node being expanded 
    ' (e.g. with the e.TreeNode.Nodes's 'Add' or 'AddRange' methods).
    '
    ' In addition to its 'Tag' property the node exposes
    ' a 'DataKey' property (which is also opaque to the node).
    ' It is often useful with 'CheckOnDemand' to associate
    ' some identifier/key of a corresponding row in a dataset.
    '
    ' With 'CheckOnExpand' specified, if this event is called 
    ' and no child nodes are added then the expansion indicator
    ' will disappear and this event will not fire again. 
    '
    ' However, this can be reset by calling the UltraTree's 
    ' 'ResetExpansionIndicator' method to re-show the expansion
    ' indicator and re-fire this event when the user expands the
    ' node again.
    '
    ' Refer to the 'UltraTree Load On Demand VB' sample.

    Dim sb As New System.Text.StringBuilder()

    sb.Append("Node: ")
    sb.Append(e.TreeNode.Key)
    sb.Append(" is about to be expanded.")

    Debug.WriteLine(sb.ToString())

    ' Note : This action can be canceled by the following line of code.
    'e.Cancel = True

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

private void ultraTree1_BeforeExpand(object sender, Infragistics.Win.UltraWinTree.CancelableNodeEventArgs e)
{

	// Note: In order to load node collections on demand, set
	// the appropriate Override object's 'ShowExpansionIndicator' 
	// property to 'CheckOnExpand'. Then in this event place 
	// logic to add the child nodes to the node being expanded 
	// (e.g. with the e.TreeNode.Nodes's 'Add' or 'AddRange' methods).
	//
	// In addition to its 'Tag' property the node exposes
	// a 'DataKey' property (which is also opaque to the node).
	// It is often useful with 'CheckOnDemand' to associate
	// some identifier/key of a corresponding row in a dataset.
	//
	// With 'CheckOnExpand' specified, if this event is called 
	// and no child nodes are added then the expansion indicator
	// will disappear and this event will not fire again. 
	//
	// However, this can be reset by calling the UltraTree's 
	// 'ResetExpansionIndicator' method to re-show the expansion
	// indicator and re-fire this event when the user expands the
	// node again.
	//
	// Refer to the 'UltraTree Load On Demand CS' sample.
	
	System.Text.StringBuilder sb = new System.Text.StringBuilder();

	sb.Append("Node: ");
	sb.Append(e.TreeNode.Key);
	sb.Append(" is about to be expanded.");

	Debug.WriteLine( sb.ToString() );

	// Note : This action can be canceled by the following line of code.
	//e.Cancel = true;
		
}
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