In this article we would like to talk a good grid control for. NET Framework, iGrid.NET. It seems it is the easiest and versatile grid Unbound you can find on the market. You can also use this as a replacement for powerful adjustable standard. NET DataGridView and DataGrid controls Windows Forms using any language. NET (C #, VB.NET, MS VC + +. NET, etc.).
Fill in the grid
Well, we'll start using it. iGrid.NET is a matrix of cells, and have it work, you simply create the required number of columns and rows, then assign values to iGrid.NET 's cell:
iGrid1.Cols.Count = 3;
iGrid1.Rows.Count = 5;
iGrid1.Cells [2 0]. Value = "Value test ";
iGrid1.Cells [3, 0]. Value = 12345;
The above code creates a grid with 3 columns and 5 rows and change the values in two cells.
Notice how easily you can access each cell through the Cells collection. Columns Cols collections and lines are used in the same iGrid way to access and lines. Note also that we store values of different types of data in the cells of the same column, no overtime.
Now we will create a more complex gate:
for (int i = 0; i
iGrid1.Cols.Add ( "col" + I. ToString (), "Column" + i.ToString ()); for (int j = 0, j Each column and row in iGrid can have its own key chain, and we used when we created our columns with the Add method of the collection of Cols. This overloaded version of the method accepts key chain with a column as the first parameter and the legend of the column as the second. After that, we can access each cell not only by their numeric index but the key chain column as well. For example, the following statement displays "40,002" (column and line keys are case insensitive): MessageBox.Show (iGrid1.Cells [3, "Col2"]. Value.ToString ()); Working with cell styles iGrid.NET is built on the cell styles. By default, each cell does not have its own object of the cell style and inherits the properties of the cell column style to which he belongs. You can use this fact to reformat the entire column in one direction. Say we need to highlight the first column with a blue 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 style required as an autonomous object in the form and apply to multiple columns to get the same formatting in these columns. For example, we'll format the values in the second and third columns as values currency with thousands separator and align right. First, we define the following object in cellular our form: Private iGCellStyle CurrencyCellStyle = iGCellStyle new (); Then we set the required properties and everything in it Simply apply this style to the 2nd and 3rd columns: CurrencyCellStyle.TextAlign = IGContentAlignment.TopRight; That's all! Custom formats in iGrid.NET are stated as if you used the String.Format method of the.NET framework. Formatting individual cells If you need to format an individual cell, you can define an object-style cell with formatting requirements and apply to this cell. But there is an easier way when you format a cell through its properties. Look at this code: iGrid1.Cells [1, 2]. BackColor = Color.Magenta; In this snippet we access the properties of the cell directly to obtain the desired view (see screenshot at right). However, if you have to format multiple cells using the same formatting, we recommend you use an object style cell for this purpose because it will simplify code and its performance. Final words We have only described the basic concept of the iGrid control, but it has more features, you should try. Among them, the text cell dynamics and cell shape, drop-down lists and powerful entry semi-automatic mode trees and many other useful functions. You can learn more about this command on the home page of the product.
iGrid1.Rows.Count = 5;
for (int i = 0; i
CurrencyCellStyle.FormatString = (0 :$#,##}";
iGrid1.Cols [1]. cellStyle = CurrencyCellStyle;
iGrid1.Cols [2]. cellStyle = CurrencyCellStyle;
iGrid1.Cells [1, 2]. ForeColor = Color.White;
iGrid1.Cells [1, 2]. Font = new Font ( "Tahoma", 8, FontStyle.Bold);