change dbgrid options at runtime

HamiD picture HamiD · May 16, 2012 · Viewed 16k times · Source

I want to change the DBGrid.Option.I found the following code:

DBGrid.Options:=DBGrid.Options + [dgEditing];
DBGrid.Options:=[dgEditing];

But do not work properly and the error [dgEditing]. I want to enable or disable the [dgEditing],[dgRowSelect] mode.

thanks a lot, a lot.

Answer

LU RD picture LU RD · May 16, 2012

When working with set types, this is how you do :

DBGrid.Options := DBGrid.Options + [dgEditing];  // Adds dbEditing option

DBGrid.Options := DBGrid.Options - [dgEditing];  // Removes dbEditing option

To change several options at once :

DBGrid.Options := DBGrid.Options + [dgEditing,dgRowSelect]; 
DBGrid.Options := DBGrid.Options + [dgEditing] + [dgRowSelect]; // Same as above