Intersoft WebGrid Documentation
AddRange Method
See Also  Example Send Feedback
ISNet.WebUI.WebGrid Namespace > WebGridCellCollection Class : AddRange Method






cells
Copies the elements of the specified WebGridCell array to the end of the collection.

Syntax

Visual Basic (Declaration) 
Public Overridable Sub AddRange( _
   ByVal cells() As WebGridCell _
) 
Visual Basic (Usage)Copy Code
Dim instance As WebGridCellCollection
Dim cells() As WebGridCell
 
instance.AddRange(cells)
C# 
public virtual void AddRange( 
   WebGridCell[] cells
)
Delphi 
public procedure AddRange( 
    cells: WebGridCellarray of
); virtual; 
JScript 
public function AddRange( 
   cells : WebGridCell[]
);
Managed Extensions for C++ 
public: virtual void AddRange( 
   WebGridCell*[]* cells
) 
C++/CLI 
public:
virtual void AddRange( 
   array<WebGridCell^>^ cells
) 

Parameters

cells

Example

The sample codes below show that you can create several cells and rows in one line of code, and add them at once using AddRange method of the collection. CreateRow is a new method of WebGridTable class which creates and initializes WebGridCell according to the columns and structures available in WebGridTable. The SetItemData method allows you to easily set an array of string which will be mapped to the cells in WebGridCellCollection respectively. The AddRange method finally perform the addition of the WebGridRow arrays to the WebGridTable.

C#Copy Code
WebGridRow[] rootRows = new WebGridRow[6];

for (int i = 0; i < 6; i++)
{
    rootRows[i] = WebGrid1.RootTable.CreateRow();
    rootRows[0].Cells.SetItemData(new string[] { "172-32-1176", "White", "Johnson" });
    rootRows[1].Cells.SetItemData(new string[] { "213-46-8915", "Green", "Marjorie" });
    rootRows[2].Cells.SetItemData(new string[] { "238-95-7766", "Carson", "Cheryl" });
    rootRows[3].Cells.SetItemData(new string[] { "267-41-2394", "O'Leary", "Michael" });
    rootRows[4].Cells.SetItemData(new string[] { "274-80-9391", "Straight", "Dean" });
    rootRows[5].Cells.SetItemData(new string[] { "341-22-1782", "Smith", "Meander" });
    WebGrid1.RootTable.Rows.AddRange(rootRows);
}

Remarks

Most significantly improved server-side object model in WebGrid.NET Enterprise 5.0 are related to new classes' constructors and overloads for commonly used classes. Now users are able to create several cells and rows in one line code, and add them at once using AddRange method of the collection. (Like shown in the example above). The enhanced server side object model in version 5.0 enables developers to access and manipulate the WebGrid control in less efforts and codes.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.