10Tec WinForms Grid: Powerful Cell Array

(iGrid.NET Control Tour, Step 1 of 9)

The main goal of iGrid is to give you a handy tool to implement tabular interfaces with the ability to highly adjust them. This is possible due to the array of iGrid cells. This functionality is available out-of-the-box without a need to define an array in your code and bind it to the 10Tec WinForms grid. Its cells are already organized into a 2-dimensional array, and iGrid provides you with a convenient way to use this array.

The simplest code sample

All what we need to use iGrid's cell array is to specify the required number of columns and rows, for example:

iGrid1.Cols.Count = 3;
iGrid1.Rows.Count = 5;

After that we can access the iGrid cells and set their values using the Cells array-like property:

iGrid1.Cells[2, 0].Value = "Test value";
iGrid1.Cells[3, 0].Value = 12345;

The two code snippets above create the following grid with 3 columns and 5 rows:

10Tec WinForms grid: array of cells

Notice that you can specify values of different data types in the cells of the same column. This allows you to easily build PropertyGrid-like interfaces like this one:

10Tec WinForms grid: PropertyGrid emulation

Column and row string keys

Every column and row in iGrid can have a string key. The string key can be used instead of the numeric index to access a column, row, or cell. To demonstrate this, let's create another grid in which we define columns with the Add() method of the Cols collection. The overloaded version we will use accepts column string key as its first parameter and column caption as the second one:

for(int i = 0; i <= 2; i++)
  iGrid1.Cols.Add($"Col {i}", $"Column {i}");

iGrid1.Rows.Count = 5;

for(int i = 0; i < iGrid1.Rows.Count; i++)
  for(int j = 0; j < iGrid1.Cols.Count; j++)
    iGrid1.Cells[i, j].Value = (i + 1) * 10000 + j;
WinForms grid code sample: access rows and columns

Having column keys, we can retrieve a cell value using the string key of its column in the same Cells array (column and row keys are case-insensitive):

var value = iGrid1.Cells[3, "Col 2"].Value;

String keys make your code more understandable. They also save your time when you modify grid structure because you will not worry about changing numeric column/row indices you would use otherwise.

Intrinsic unbound mode and excellent performance

iGrid works in unbound mode, but this does not mean you cannot create data-bound grids. You can upload data from ADO.NET data sources with the FillWithData() method in one call and optionally, if you need data binding, implement it exactly the way you need with iGrid's rich object and event model.

Operations with the iGrid cell array are extremely effective due to internal page organization and other optimizations like .NET native pointer arithmetic. Tasks like adding/inserting many rows into the grid, especially when the number of rows to add is not known beforehand, are performed very quickly. Your work is just to put data into iGrid cells and format them; iGrid does the rest to provide your users with excellent performance!

iGrid.NET cell formatting options »