Board index » delphi » TDBGrid (D2)

TDBGrid (D2)

Hi all,
I have a DBGrid (records in the DBGrid come from a Table) and Button
components on a Form. If Button.Enabled property is True depends on what
Value one of fields in selected record has (e.g.:
Button.Enabled:=Table.FieldByName('CardNo').Value>0;). The problem is
that I don't know (thus far) which procedure (event) of which component
I should use. I tried with Table.AfterPost (.AfterCancel and so on), but
it's OK only if someone changes content of the database file. I want to
examine value of 'CardNo' field every time someone moves from one record
to another one (even without editing it). I used DBGrid.OnDrawColumnCell
too, but this procedure (although is called every time you move among
records) seems to be not good for me (sometimes it happens that DBGrid
shows that I am on the first record in the table, but
Table.FieldByName(CardNo').Value examined by OnDrawColumnCell has still
the value of this field in the second record! - this is the same problem
as this, that although you are at the end(beginning) of the Table you
must call 'Table.Next(Prior)' procedure to set 'Table.EOF(BOF)' to true
- a bug?)
Any ideas? Thanks in advance.

Re:TDBGrid (D2)

Wojtek -

Try using the AfterScroll event handler. In there, set your Button's
Enabled property.

Good luck.


Other Threads