Version

ParentRow Property (BeforeRowInsertEventArgs)

The parent row (read-only)
Syntax
'Declaration
 
Public ReadOnly Property ParentRow As UltraGridRow
public UltraGridRow ParentRow {get;}
Example
Following code illustrates some of the information available in BeforeRowInsert event and its potential uses.

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.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub UltraGrid1_BeforeRowInsert(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeRowInsertEventArgs) Handles ultraGrid1.BeforeRowInsert

       ' BeforeRowInsert gets fired when the user clicks on an add-new button in
       ' the add-new-box to add a row. This event gives you a chance to prevent
       ' the user from doing so conditionally by setting Cancel to true.

       ' You can also access the rows collection the row would be added to.
       Dim rowsColl As RowsCollection = Nothing
       If Nothing Is e.ParentRow Then
           ' If ParentRow is null, then the row is being added to the topmost rows collection
           ' which can be accessed by using the Rows property off the UltraGrid.
           rowsColl = Me.ultraGrid1.Rows
       Else
           ' If ParentRow is non-null, then the row is being added to a descendant band. Here
           ' is how you can get the rows collection.
           rowsColl = e.ParentRow.ChildBands(e.Band).Rows
       End If

       Debug.WriteLine("Row is being added to rows collection with " & rowsColl.Count.ToString() & " number of rows.")

       Dim result As DialogResult = MessageBox.Show("You are about to add a row to " & e.Band.Key & ". Continue ?", _
                                                       "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

       ' Set cancel to stop the UltraGrid from proceeding with adding of a new row.
       If DialogResult.No = result Then
           e.Cancel = True
       End If

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

private void ultraGrid1_BeforeRowInsert(object sender, Infragistics.Win.UltraWinGrid.BeforeRowInsertEventArgs e)
{

	// BeforeRowInsert gets fired when the user clicks on an add-new button in
	// the add-new-box to add a row. This event gives you a chance to prevent
	// the user from doing so conditionally by setting Cancel to true.

	// You can also access the rows collection the row would be added to.
	RowsCollection rowsColl = null;
	if ( null == e.ParentRow )
	{
		// If ParentRow is null, then the row is being added to the topmost rows collection
		// which can be accessed by using the Rows property off the UltraGrid.
		rowsColl = this.ultraGrid1.Rows;
	}
	else
	{
		// If ParentRow is non-null, then the row is being added to a descendant band. Here
		// is how you can get the rows collection.
		rowsColl = e.ParentRow.ChildBands[ e.Band ].Rows;
	}

	Debug.WriteLine( "Row is being added to rows collection with " + rowsColl.Count.ToString( ) + " number of rows." );

	DialogResult result = MessageBox.Show( 
		"You are about to add a row to " + e.Band.Key + ". Continue ?", "Confirm",
		MessageBoxButtons.YesNo, MessageBoxIcon.Question );

	// Set cancel to stop the UltraGrid from proceeding with adding of a new row.
	if ( DialogResult.No == result )
		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