Articlear article directory.
Translate Page To German Tranlate Page To Spanish Translate Page To French Translate Page To Italian Translate Page To Japanese Translate Page To Korean Translate Page To Portuguese Translate Page To Chinese
  Number Times Read : 73    Word Count: 500  
Categories

Accounting
Beauty
Business
Career
Cars and Trucks
Computers
Culture and Society
Environment
Family
Finance
Fitness
Food and Drink
Health
Hobbies
Home
Humor
Inspiration/Motivation
Internet
Internet Marketing
Legal
Marketing
Men
Music
Personal Development
Pets and Animals
Politics
Psychology
Publishing
Recreation & Leisure
Root Category
Science
Speaking
Technology
Tools & Resources
Uncatagorized Misc.
Women
Writing
 
Stats
Total Articles: 72
Total Authors: 16951
Total Downloads: 2004563


Newest Member
Browning Tattum

 


   

10Tec iGrid.NET, the easiest unbound grid replacement for .NET DataGrid/DataGridView



[Valid RSS feed]  Category Rss Feed - http://www.articlear.com/rss.php?rss=605
By : Svietlana Malyshevska    29 or more times read
Submitted 2010-01-11 02:46:36
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:

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.
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/).
Article From Articlear.com

Related Articles

HTML Ready Article. Click on the "Copy" button to copy into your clipboard.




Firefox users please select/copy/paste as usual
Rate This Article
Vote to see the results!

Do you like this article?
  • Yes.
  • Not Sure.
  • No.
New Members
select
Sign up
select
learn more
Affiliate Sign in
 
Nav Menu
Home
Login
Submit Articles
Submission Guidelines
Top Articles
Link Directory
About Us
Contact Us
Privacy Policy
RSS Feeds

Actions
Print This Article
Add To Favorites

 
Sponsors