[]
        
(Showing Draft Content)

C1.Win.FlexGrid.C1FlexGridBase.SetData

SetData Method

SetData(int, int, object, bool)

Assigns a value to a grid cell.

Declaration
public virtual bool SetData(int row, int col, object value, bool coerce)
Parameters
Type Name Description
int row

Row index.

int col

Column index.

object value

Value to assign to the cell.

bool coerce

Whether the value should be converted to the column's data type.

Returns
Type Description
bool

True if the value was assigned to the cell.

Remarks

If coerce is set to true and the value can't be converted into the proper data type, the grid will fire the GridError event and the cell will retain its original value.

Using SetData(int, int, object, bool) with coerce set to true is equivalent to setting the grid's indexer. For example, the following lines of code are equivalent:

flex.SetData(1, 1, "Hello", true);
flex[1, 1] = "Hello"; // same thing

SetData(CellRange, object, bool)

Assigns a value to a range of cells.

Declaration
public virtual bool SetData(CellRange rg, object value, bool coerce)
Parameters
Type Name Description
CellRange rg

CellRange that specifies the cells that will be assigned a new value.

object value

Value that will be assigned to all cells in the range.

bool coerce

Whether the value should be converted to the column's data type.

Returns
Type Description
bool

True if the value was assigned to all cells in the destination range.

SetData(int, int, object)

Assigns a value to a grid cell, coercing the value into the cell's specified DataType.

Declaration
public virtual bool SetData(int row, int col, object value)
Parameters
Type Name Description
int row

Row index.

int col

Column index.

object value

Value to assign to the cell.

Returns
Type Description
bool

True if the value was assigned to the cell, false if the value could not be assigned (usually because it could not be converted to the appropriate type).

SetData(CellRange, object)

Assigns a value to a range of cells, coercing the value into each cell's specified DataType.

Declaration
public virtual bool SetData(CellRange rg, object value)
Parameters
Type Name Description
CellRange rg

CellRange that specifies the cells that will be assigned a new value.

object value

Value that will be assigned to all cells in the range.

Returns
Type Description
bool

True if the value was assigned to all cells in the destination range, false if the value could not be assigned to all cells in the range (usually because it could not be converted to the appropriate type).

SetData(int, string, object, bool)

Assigns a value to a grid cell.

Declaration
public virtual bool SetData(int row, string colName, object value, bool coerce)
Parameters
Type Name Description
int row

Row index.

string colName

Column name.

object value

Value to assign to the cell.

bool coerce

Whether the value should be converted to the column's data type.

Returns
Type Description
bool

True if the value was assigned to the cell, False otherwise.

Remarks

If coerce is set to true and the value can't be converted into the proper data type, the grid will fire the GridError event and the cell will retain its original value.

Using SetData(int, int, object, bool) with coerce set to true is equivalent to setting the grid's indexer. For example, the following lines of code are equivalent:

flex.SetData(1, "ColName", "Hello", true);
flex[1, "ColName"] = "Hello"; // same thing

SetData(int, string, object)

Assigns a value to a grid cell, coercing the value into the cell's specified data type.

Declaration
public virtual bool SetData(int row, string colName, object value)
Parameters
Type Name Description
int row

Row index.

string colName

Column name.

object value

Value to assign to the cell.

Returns
Type Description
bool

True if the value was assigned to the cell, False otherwise.