Infragistics(R) NetAdvantage(R) Windows Forms
DefaultCellValue Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraGridColumn Class : DefaultCellValue Property

Gets or sets the default cell value that will be assigned when new rows are added via the add-row feature or the add-new box.

Syntax

Visual Basic (Declaration) 
Public Property DefaultCellValue As Object
C# 
public object DefaultCellValue {get; set;}

Example

Following sample code shows some of the add-row feature related properties available.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
        ' Setting the AllowAddNew to TemplateOnBottom, TemplateOnTop or TemplateOnTopWithTabRepeat
        ' turns on the add-row functionality.
        Me.UltraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom

        ' You can use the TemplateAddRowAppearance to set the appearance of template add-rows.
        Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowAppearance.BackColor = Color.Blue
        Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowAppearance.ForeColor = Color.Yellow

        ' You can also use the TemplateAddCellRowAppearance to set the appearance of cells in
        ' the template add-rows.
        Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.BackColor = Color.Blue
        Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.ForeColor = Color.Yellow

        ' You can use the AddRowAppearance to set the appearance of add-row. A template add-row
        ' becomes an add-row when the user enters the edit mode and types something in a template
        ' add-row.
        Me.UltraGrid1.DisplayLayout.Override.AddRowAppearance.BackColor = Color.DarkRed
        Me.UltraGrid1.DisplayLayout.Override.AddRowAppearance.ForeColor = Color.Orange

        ' You can use the AddRowCellAppearance to set the appearance of cells in the add-rows.
        Me.UltraGrid1.DisplayLayout.Override.AddRowCellAppearance.BackColor = Color.DarkRed
        Me.UltraGrid1.DisplayLayout.Override.AddRowCellAppearance.ForeColor = Color.Orange

        ' You can also control the spacing before and after the template add-rows.
        Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowSpacingBefore = 5
        Me.UltraGrid1.DisplayLayout.Override.TemplateAddRowSpacingAfter = 5

        ' You can also specify a different border style for template add-rows to distinguish
        ' them from the regular rows.
        Me.UltraGrid1.DisplayLayout.Override.BorderStyleTemplateAddRow = UIElementBorderStyle.Raised

        ' Use the DefaultCellValue property of the column to specify the default values that
        ' should be assigned to the add-row.
        Me.UltraGrid1.DisplayLayout.Bands(0).Columns(0).DefaultCellValue = "(Empty)"

        ' You can display a prompt in the add-row by setting the TemplateAddRowPrompt 
        ' proeprty. By default UltraGrid does not display any add-row prompt.
        e.Layout.Override.TemplateAddRowPrompt = "Click here to add a new record..."

        ' You can control the appearance of the prompt using the Override's
        ' TemplateAddRowPromptAppearance property. By default the prompt is
        ' transparent. You can make it non-transparent by setting the appearance'
        ' BackColorAlpha property or by setting the BackColor to a desired value.
        e.Layout.Override.TemplateAddRowPromptAppearance.ForeColor = Color.Maroon
        e.Layout.Override.TemplateAddRowPromptAppearance.FontData.Bold = DefaultableBoolean.True

        ' By default the prompt is displayed across multiple cells. You can confine
        ' the prompt a particular cell by setting the SpecialRowPromptField property
        ' of the band to the key of the column that you want to display the prompt in.
        e.Layout.Bands(0).SpecialRowPromptField = e.Layout.Bands(0).Columns(1).Key

    End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
		{
			// Setting the AllowAddNew to TemplateOnBottom, TemplateOnTop or TemplateOnTopWithTabRepeat
			// turns on the add-row functionality.
			this.ultraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom;
			
			// You can use the TemplateAddRowAppearance to set the appearance of template add-rows.
			this.ultraGrid1.DisplayLayout.Override.TemplateAddRowAppearance.BackColor = Color.Blue;
			this.ultraGrid1.DisplayLayout.Override.TemplateAddRowAppearance.ForeColor = Color.Yellow;

			// You can also use the TemplateAddCellRowAppearance to set the appearance of cells in
			// the template add-rows.
			this.ultraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.BackColor = Color.Blue;
			this.ultraGrid1.DisplayLayout.Override.TemplateAddRowCellAppearance.ForeColor = Color.Yellow;

			// You can use the AddRowAppearance to set the appearance of add-row. A template add-row
			// becomes an add-row when the user enters the edit mode and types something in a template
			// add-row.
			this.ultraGrid1.DisplayLayout.Override.AddRowAppearance.BackColor = Color.DarkRed;
			this.ultraGrid1.DisplayLayout.Override.AddRowAppearance.ForeColor = Color.Orange;

			// You can use the AddRowCellAppearance to set the appearance of cells in the add-rows.
			this.ultraGrid1.DisplayLayout.Override.AddRowCellAppearance.BackColor = Color.DarkRed;
			this.ultraGrid1.DisplayLayout.Override.AddRowCellAppearance.ForeColor = Color.Orange;

			// You can also control the spacing before and after the template add-rows.
			this.ultraGrid1.DisplayLayout.Override.TemplateAddRowSpacingBefore = 5;
			this.ultraGrid1.DisplayLayout.Override.TemplateAddRowSpacingAfter  = 5;

			// You can also specify a different border style for template add-rows to distinguish
			// them from the regular rows.
			this.ultraGrid1.DisplayLayout.Override.BorderStyleTemplateAddRow = UIElementBorderStyle.Raised;

			// Use the DefaultCellValue property of the column to specify the default values that
			// should be assigned to the add-row.
			this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].DefaultCellValue = "(Empty)";

			// You can display a prompt in the add-row by setting the TemplateAddRowPrompt 
			// proeprty. By default UltraGrid does not display any add-row prompt.
			e.Layout.Override.TemplateAddRowPrompt = "Click here to add a new record...";

			// You can control the appearance of the prompt using the Override's
			// TemplateAddRowPromptAppearance property. By default the prompt is
			// transparent. You can make it non-transparent by setting the appearance'
			// BackColorAlpha property or by setting the BackColor to a desired value.
			e.Layout.Override.TemplateAddRowPromptAppearance.ForeColor = Color.Maroon;
			e.Layout.Override.TemplateAddRowPromptAppearance.FontData.Bold = DefaultableBoolean.True;

			// By default the prompt is displayed across multiple cells. You can confine
			// the prompt a particular cell by setting the SpecialRowPromptField property
			// of the band to the key of the column that you want to display the prompt in.
			e.Layout.Bands[0].SpecialRowPromptField = e.Layout.Bands[0].Columns[1].Key;
		}

See Also