Editing DBGrid


I'm using TADVDBGrid to view/edit an ADO Table. Because I would like to take advantage of filtering features, the PageMode is set to False in DBGrid. Therefore, records are not updated when cell content are changed. How can I update the database after changes are made? I have tried executing a routine before closing the program that checks every row to see whether they were modified. This works fine. However, when I access the content of a cell (using Cells[][], DisplCells[][], RealCells[][]), the value returned is the original and not the modified by the user. Any suggestions?

Best regards,


Editing is handled automatically when grid.PageMode = true.

When grid.PageMode = false, this is not the case. If you want editing with grid.PageMode = false, you could implement the OnCellValidate event and from this event directly update the value passed as Value parameter of this event in the DB field being edited.

Thanks Bruno,

 I'm trying to update the database before closing the application by checking the modified rows. The problem that I have is that I'm not able to access the content of the modified cells. I have tried using Cells, DisplCells and RealCells. Does AdvDBGrid stores the information in another property?



When grid.PageMode = false, the updated cell values can be accessed via grid.Cells[col,row]: string

Hello Bruno,

Everything works well when the grid is not filtered. However, when the grid is filtered by one or more columns, then I have the feeling that i"m not accessing the correct raw. 

This is a snippet of the routine that it is called before closing the application

for( int i = 2; i < DBAdvGrid1->TotalRowCount(); i++)
if( DBAdvGrid1->RowModified )
PhysicalProperties_DM->ADOT_Properties->FieldByName("MW")->Value = DBAdvGrid1->Cells[DBAdvGrid1->ColumnPosition(6)].ToDouble();



If you use filtering, you'd need a DB key value in the grid and perform a locate on this DB key for each row where you need to do an update.