ARTICLE search:   

 
Free-Article-Directory » Programming-Articles » View Article
Article Author:
Svietlana Malyshevska



10Tec Company: Article: Introduction to iGrid.NET


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 (http://www.10Tec.com/). 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:



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

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.


Now let's create a more complex grid:



for(int i=0; i<=2; i++)
iGrid1.Cols.Add("col" + i.ToString(), "Column " + i.ToString());
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;

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):



MessageBox.Show(iGrid1.Cells[3, "COL2"].Value.ToString());

Working with cell styles


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:



iGrid1.Cols[0].CellStyle.BackColor = Color.CornflowerBlue;

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:



CurrencyCellStyle.TextAlign = iGContentAlignment.TopRight;
CurrencyCellStyle.FormatString = "{0:$#,##}";
iGrid1.Cols[1].CellStyle = CurrencyCellStyle;
iGrid1.Cols[2].CellStyle = CurrencyCellStyle;

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:



iGrid1.Cells[1, 2].BackColor = Color.Magenta;
iGrid1.Cells[1, 2].ForeColor = Color.White;
iGrid1.Cells[1, 2].Font = new Font("Tahoma", 8, FontStyle.Bold);

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 at http://www.10Tec.com/Products/dotNET/iGrid.NET/index.aspx.



See All Articles
From This Author
 

Log Yourself In
Usermail
Password
 
Forgot Password? New User?

Help Support The Free Article Directory.
  Click button above to help keep the our article directory alive.
Each month more and more users join the free article directory, increasing the server resources, bandwidth and other associated costs.
Please show your support and make a donation, however small it will make a difference.
 
Article Categories


Article Directory Newsletter
Enter your e-mail address below to join:

 
We hate spam as much as you do, thats why we will only send you article directory related content.


Submit This Page To Your Favourite
Social Bookmaking Site:






Top 10 Authors
Article Directory Stat's

Jamie Hanson ( 1407 articles)
Payal Jindal ( 1187 articles)
stickystebee ( 875 articles)
Karl Donald ( 865 articles)
Rick Lee ( 769 articles)
Mairead Foley ( 708 articles)
Alan Smith ( 591 articles)
artavia.seo ( 571 articles)
Lindsy Emery ( 508 articles)
Ben Dave ( 443 articles)

We Now Have.

50 Categories.
126297 Free Articles.
2441 Articles Waiting For Approval.
33774 Registered Users.

Thank you for using our
Free Article Directory.

Please Don't Forget To Bookmark Us!