Version

AddNewBox Property (UltraGridLayout)

The AddNewBox object represents the AddNew Box interface for entering new data rows into the grid.
Syntax
'Declaration
 
Public ReadOnly Property AddNewBox As AddNewBox
public AddNewBox AddNewBox {get;}
Remarks

When a grid is being used to display a flat recordset, the conventional approach for adding data has been to place an empty row at the bottom of the grid. New data is entered into this row and appended to the data source, then the row reserved for new data entry is cleared and moved down to appear below the newly added row. However, when working with a hierarchical recordset, this metaphor is no longer effective. Multiple bands of data are represented as distinct groups of rows, and which group of rows receives the new data is significant. Simply adding new data to the last row in a band will not position the new record correctly with respect to the band's parent recordset.

To effectively add new data to a hierarchical recordset, the UltraGrid implements an interface called the "AddNew Box." The AddNew Box displays one or more buttons that are used to trigger the addition of new data. The number of buttons corresponds to the number of hierarchical bands displayed. Each band has its own AddNew button, and connecting lines link the buttons, illustrating a hierarchical relationship that mirrors that of the data.

To use the AddNew Box, you first set focus to a row or cell in the band to which you want to add data. You should determine where in the hierarchy you want the record to appear, then select a record that corresponds to that location. You then click the AddNew button for the band you want to contain the new data, and an empty data entry row appears in the band a the point you selected. For example, if you have a Customers/Orders hierarchy and you wanted to add data for a new order, you would first locate the customer to whom the order belonged, select that customer's record (or one of that customer's existing order records) and click the AddNew button for the Orders band. A blank row would appear below any existing orders that were displayed for the customer.

The AddNewBox object contains properties that control the various attributes of the AddNew Box interface. For example, you can use the Hidden property of the AddNewBox object to selectively display or hide the interface, thus enabling or disabling the user's ability to add new data. You can also use this object to control the appearance of the AddNew buttons, and specify other formatting features. You can also chose between the standard and compact display styles for the AddNew Box. The compact style preserves screen space by compressing the display of the AddNew buttons and eliminating the display of a hierarchical structure.

Example
Following code configures the look of add-new-box in the ultragrid. Add-new-box allows easy adding of rows by clicking on add new buttons in it. Each add new button in add-new-box corresponds to a band in the ultragrid.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button3.Click

      ' Make the addnew box visible.
      Me.UltraGrid1.DisplayLayout.AddNewBox.Hidden = False

      ' Change the prompt on the add new box.
      Me.UltraGrid1.DisplayLayout.AddNewBox.Prompt = "Add a new row"

      ' Make the add new box compact to save space.
      Me.UltraGrid1.DisplayLayout.AddNewBox.Style = AddNewBoxStyle.Compact

      ' Set the back color of the add new box area and set the border style to etched.
      Me.UltraGrid1.DisplayLayout.AddNewBox.Appearance.BackColor = Color.White
      Me.UltraGrid1.DisplayLayout.AddNewBox.BorderStyle = UIElementBorderStyle.Etched

      ' Configure the way button connectors look
      Me.UltraGrid1.DisplayLayout.AddNewBox.ButtonConnectorStyle = UIElementBorderStyle.Etched
      Me.UltraGrid1.DisplayLayout.AddNewBox.ButtonConnectorColor = Color.Red

      ' Configure the way buttons look.
      ' Set the buttons' style to PopupSoft and set the appearance of the buttons.
      Me.UltraGrid1.DisplayLayout.AddNewBox.ButtonStyle = UIElementButtonStyle.PopupSoft
      Me.UltraGrid1.DisplayLayout.AddNewBox.ButtonAppearance.BackColor = Color.SkyBlue
      Me.UltraGrid1.DisplayLayout.AddNewBox.ButtonAppearance.BackColor2 = Color.Blue
      Me.UltraGrid1.DisplayLayout.AddNewBox.ButtonAppearance.BackGradientStyle = GradientStyle.Horizontal

      ' You can also customize the caption of the buttons that show up in the add-new-box.
      ' Each band has a button in the add-new-box. You can change the caption of these
      ' buttons by setting the AddButtonCaption property off the bands. You can also set
      ' the tool-tip text for those buttons as well by setting AddButtonToolTipText property.
      Me.UltraGrid1.DisplayLayout.Bands("Customers").AddButtonCaption = "New Customer"
      Me.UltraGrid1.DisplayLayout.Bands("Customers").AddButtonToolTipText = "Click to add a new Customers record."

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

private void button3_Click(object sender, System.EventArgs e)
{

	// Make the addnew box visible.
	this.ultraGrid1.DisplayLayout.AddNewBox.Hidden = false;

	// Change the prompt on the add new box.
	this.ultraGrid1.DisplayLayout.AddNewBox.Prompt = "Add a new row";
          
	// Make the add new box compact to save space.
	this.ultraGrid1.DisplayLayout.AddNewBox.Style = AddNewBoxStyle.Compact;
	
	// Set the back color of the add new box area and set the border style to etched.
	this.ultraGrid1.DisplayLayout.AddNewBox.Appearance.BackColor = Color.White;
	this.ultraGrid1.DisplayLayout.AddNewBox.BorderStyle = UIElementBorderStyle.Etched;

	// Configure the way button connectors look
	this.ultraGrid1.DisplayLayout.AddNewBox.ButtonConnectorStyle = UIElementBorderStyle.Etched;
	this.ultraGrid1.DisplayLayout.AddNewBox.ButtonConnectorColor = Color.Red;
	
	// Configure the way buttons look.
	// Set the buttons' style to PopupSoft and set the appearance of the buttons.
	this.ultraGrid1.DisplayLayout.AddNewBox.ButtonStyle = UIElementButtonStyle.PopupSoft;
	this.ultraGrid1.DisplayLayout.AddNewBox.ButtonAppearance.BackColor = Color.SkyBlue;
	this.ultraGrid1.DisplayLayout.AddNewBox.ButtonAppearance.BackColor2 = Color.Blue;
	this.ultraGrid1.DisplayLayout.AddNewBox.ButtonAppearance.BackGradientStyle = GradientStyle.Horizontal;

	// You can also customize the caption of the buttons that show up in the add-new-box.
	// Each band has a button in the add-new-box. You can change the caption of these
	// buttons by setting the AddButtonCaption property off the bands. You can also set
	// the tool-tip text for those buttons as well by setting AddButtonToolTipText property.
	this.ultraGrid1.DisplayLayout.Bands["Customers"].AddButtonCaption = "New Customer";
	this.ultraGrid1.DisplayLayout.Bands["Customers"].AddButtonToolTipText = "Click to add a new Customers record.";

}
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