It's not difficult to do. Here's the code you need.
Retrieving or setting data in the current grid cell it's easy to locate the current cell in a TCBGrid
and modify its contents. Use the following code:
if(dgData->SelectedField)// The property is Null if no cell is selected
ShowMessage(dgData->SelectedField->Test);
//display the contents of the current cell.
to alter the cell, use this code:
TDataSet *ds = dgData->DataSource->DataSet;
//get the dataset feeding the grid named dgData
if (ds->State == dsBrowse)
ds->Edit();
//Make sure data set is in Edit or Insert Mode.
dgData->SelectedField->Value = 123.456; //Modify the field's contents.
ds->Post(); //Save the change.
by Jim Bailey, JimBailey@worldnet.att.net
 |