Version

Using AddRow Feature

The AddRow feature allows the user to conveniently add rows. This feature displays an AddRow template at the top or bottom of the Rows collection. To add a row, the user simply clicks in the AddRow template and starts to type.

To use the AddRow feature:

  1. Before you start writing any code, you should place using/imports directives in your code-behind so you don’t need to always type out a member’s fully qualified name.

In Visual Basic:

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

In C#:

using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
  1. The Add Row can be turned on by setting the AllowAddNew property of the Override object to one of following settings: TemplateOnTop, TemplateOnTopWithTabRepeat or TemplateOnBottom.

In Visual Basic:

' Displays the add-row on top of each rows collection.
Me.UltraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnTop

In C#:

// Displays the add-row on top of each rows collection.
this.ultraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnTop;
  1. By default, template Add Rows are colored with a shade of the row colors. Template Add Row appearance can be controlled by using TemplateAddRowAppearance and TemplateAddRowCellAppearance properties.

In Visual Basic:

Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.BackColor = _
  Color.Yellow
Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.ForeColor = _
  Color.LightYellow

In C#:

this.ultraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.BackColor = Color.Yellow;
this.ultraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.ForeColor = Color.LightYellow;
  1. Once the user starts typing into a template Add Row, it becomes simply an "Add Row". Add Row appearance can also be controlled.

In Visual Basic:

Me.UltraGrid1.DisplayLayout.Override.AddRowCellAppearance.BackColor = _
  Color.LightYellow
Me.UltraGrid1.DisplayLayout.Override.AddRowCellAppearance.ForeColor = _
  Color.Black

In C#:

this.ultraGrid1.DisplayLayout.Override.AddRowCellAppearance.BackColor = Color.LightYellow;
this.ultraGrid1.DisplayLayout.Override.AddRowCellAppearance.ForeColor = Color.Black;

The following snapshot displays a template Add Row.

use the addrow feature in ultragrid

Once the user starts typing into the Template Add Row, it becomes an "Add Row". A new Template Add Row is created and displayed so the user can continue adding more rows.

use the addrow feature in ultragrid
  1. Default values for the new rows can be set as well.

In Visual Basic:

Me.UltraGrid1.DisplayLayout.Bands(0).Columns("Country").DefaultCellValue = "US"

In C#:

this.ultraGrid1.DisplayLayout.Bands[0].Columns["Country"].DefaultCellValue = "US";