FlexGrid for WinForms
Item(Int32,Int32) Property
Example 



Gets or sets the data in a grid cell.
Syntax
'Declaration
 
Public Overloads Property Item( _
   ByVal row As Integer, _
   ByVal col As Integer _
) As Object
'Usage
 
Dim instance As C1FlexGridBase
Dim row As Integer
Dim col As Integer
Dim value As Object
 
instance.Item(row, col) = value
 
value = instance.Item(row, col)
public object Item( 
   int row,
   int col
) {get; set;}
public:
property Object^ Item {
   Object^ get(int row, int col);
   void set (int row, int col, Object^ value);
}

Parameters

row
col
Remarks

This is one of the indexers you can use to get or set the data stored in grid cells.

You can index cells using the row and column indices or using the row index and column name.

Using integer indices is more efficient, because the grid doesn't have to look up the column. Using column names is more flexible, because references remain valid even if the user moves columns to a new position.

When assigning a value to a cell, the grid tries to convert it into the type specified for the column (see the RowCol.DataType property). If the grid can't convert the value, it fires the GridError event and the cell retains its original value.

Example
The example below creates a column and assigns it a name, then sets the value of a cell using the column index and retrieves the value using the column name:
// create a column, assign it a name and get the new index
Column myCol = flex.Cols.Add();
myCol.Name = "address";
myCol.DataType = typeof(string);
int colIndex = myCol.Index;
            
// assign a value to a cell using cell coordinates:
flex[1, colIndex] = "555, Broadway";
            
// get the value using the column name
string address = (string)flex[1, "address"];
MessageBox.Show("The address is " + address);
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

C1FlexGridBase Class
C1FlexGridBase Members
Overload List

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback