Xceed DataGrid for WPF v7.2 Documentation
InitializingInsertionRow Event (DataGridControl)
Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DataGridControl Class : InitializingInsertionRow Event
Raised when an InsertionRow in the grid is being initialized.
Syntax
'Declaration
 
Public Event InitializingInsertionRow As EventHandler(Of InitializingInsertionRowEventArgs)
'Usage
 
Dim instance As DataGridControl

Dim handler As EventHandler(Of InitializingInsertionRowEventArgs)

 

AddHandler instance.InitializingInsertionRow, handler
public event EventHandler<InitializingInsertionRowEventArgs> InitializingInsertionRow
Event Data

The event handler receives an argument of type InitializingInsertionRowEventArgs containing data related to this event. The following InitializingInsertionRowEventArgs properties provide information specific to this event.

PropertyDescription
Gets or sets the InsertionRow to initialize.  
Example
All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
The following example demonstrates how to initialize the values of the ShipCountry, ShipCity, and ShipVia columns in an insertion row located in the fixed headers. The handler for the InitializingInsertionRow event is defined in the code-behind class. The columns that are contained in the grid will be limited to those specified in the ItemProperties of the DataGridCollectionViewSource.
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">

  <Grid.Resources>

    <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"

                                    Source="{Binding Source={x:Static Application.Current},

                                                        Path=Orders}"

                                    AutoCreateItemProperties="False">

      <xcdg:DataGridCollectionViewSource.ItemProperties>

        <xcdg:DataGridItemProperty Name="ShipCountry" Title="Country"/>

        <xcdg:DataGridItemProperty Name="ShipCity" Title="City"/>

        <xcdg:DataGridItemProperty Name="ShipVia" Title="Ship With"/>

      </xcdg:DataGridCollectionViewSource.ItemProperties>

    </xcdg:DataGridCollectionViewSource>

   </Grid.Resources>





   <xcdg:DataGridControl x:Name="OrdersGrid"

                         ItemsSource="{Binding Source={StaticResource cvs_orders}}"

                         InitializingInsertionRow="InitInsertion">

       <xcdg:DataGridControl.View>

         <xcdg:CardView>



           <xcdg:CardView.FixedHeaders>

              <DataTemplate>

                 <xcdg:InsertionRow/>

              </DataTemplate>

           </xcdg:CardView.FixedHeaders>

         </xcdg:CardView>

      </xcdg:DataGridControl.View>

   </xcdg:DataGridControl>

</Grid>
Private Sub InitInertion( ByVal sender As Object, ByVal e As InitializingInsertionRowEventArgs )

   e.InsertionRow.Cells( "ShipCountry" ).Content = 

              Me.ParseCountry( System.Globalization.CultureInfo.CurrentCulture.DisplayName )

   e.InsertionRow.Cells( "ShipCity" ).Content = "Enter City Here"

   e.InsertionRow.Cells( "ShipVia" ).Content = 1

End Sub

Private Function ParseCountry( ByVal name As String ) As String

   Dim startIndex As Integer = name.IndexOf( "(" )

   Return name.SubString( startIndex + 1, name.Length - startIndex - 2 )

End Function
private void InitInsertion( object sender, InitializingInsertionRowEventArgs e )

{

   e.InsertionRow.Cells[ "ShipCountry" ].Content = 

         this.ParseCountry( System.Globalization.CultureInfo.CurrentCulture.DisplayName );

   e.InsertionRow.Cells[ "ShipCity" ].Content = "Enter City Here";

   e.InsertionRow.Cells[ "ShipVia" ].Content = "1";

}

private string ParseCountry( string name )

{

   int startIndex = name.IndexOf( "(" );

   return name.Substring( startIndex + 1, name.Length - startIndex - 2 );

}
Requirements

Target Platforms: Windows 11, Windows, 10, 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