10Tec iGrid.NET, the easiest unbound grid replacement for .NET DataGrid/DataGridView
In this article we would like to tell you about a beautiful grid control for the .NET Framework, iGrid.NET. It seems, it is the easiest and versatile unbound grid you can find on the market. You can also use this component as a powerful adjustable replacement for the standard .NET DataGrid and DataGridView controls on the Windows Forms using any .NET language (C#, VB.NET, MS VC++.NET, etc).
Populating the grid
Well, let's start to use it. iGrid.NET is a cell matrix, and to get it working, you simply create the required number of columns and rows and then assign values to iGrid.NET's cells:
The code above creates a grid with 3 columns and 5 rows and changes the values in its two cells.
Notice how easily you can access each cell through the Cells collection. The Cols and Rows collections are used the same way to access iGrid's columns and rows. Also notice that we store values of different data types in cells of the same column without any additional work.
Each column and row in iGrid can have its own string key, and we used it when we created our columns with the Add method of the Cols collection. That overloaded version of the method accepts a column's string key as its first parameter and the column's caption as the second one.
After that we can access each cell not only by its numeric index but by its column's string keys too. For instance, the following statement displays "40002" (column and row keys are case-insensitive):
iGrid.NET is built on cell styles. By default, each cell does not have its own cell style object and inherits the properties of the cell style object of the column it belongs to. You can use this fact to reformat the entire column in one statement.
Let's say we need to highlight the first column with a blue color like on the screenshot. In igrid.NET this can be done with the following statement:
We can also create a required style as a standalone object on the form's level and apply it to several columns to get the same formatting in those columns. As an example, let's format the values in the second and third columns as currency values with thousand separator and align them to right.
First, we define the following cell style object in our form:
private iGCellStyle CurrencyCellStyle = new iGCellStyle();
Then we set the required properties in it and simply apply this style to the 2nd and 3rd columns:
That's all! Custom formats in iGrid.NET are specified as if you used the String.Format method from the .NET Framework.
Formatting individual cells
If you need to format an individual cell, you can define a cell style object with required formatting and apply it to this cell. But there is a simpler way when you format a cell through its properties. Look at this code:
In this code snippet we access the cell's properties directly to get the desired view (see the screenshot at right).
However, if you need to format several cells using the same formatting, we recommend that you use a cell style object for this purpose as it will simplify your code and its performance.
Final words
We described only the basic concept of the iGrid control, but it has much more features you should try. Among them dynamic cell texts and cell formatting, powerful drop-down and auto-complete lists, tree mode and many other useful functions. You can find out more about this control on the product's home page.
Author Resource:-
About the Author:
Senior Developer, an accounting system automatization specialist, ActiveX/.NET developer. An active user of iGrid, a .NET grid, .NET DataGrid/DataGridView replacement (http://www.10tec.com/).