Board index » cppbuilder » TDBGrid->DataSet->RecNo is always -1

TDBGrid->DataSet->RecNo is always -1

Hi for all,

I have a little form with one DBGrid, I want to fill all 2nd row in the
with another color (clTeal, but the RecNo event is always -1.

In the helpfile :
"As implemented in TDataSet, the value of RecNo is always -1. Ordinarily
an application does not access RecNo at the TDataSet level. Instead a
redeclared and implemented RecNo property in a descendant class such as
TTable is accessed."

The DataSource comes from the Owner component, the DataSet is a TQuery
from the Owner.

My Code is:
void __fastcall TListFrm::GridDrawColumnCell(TObject *Sender,
      const TRect &Rect, int DataCol, TColumn *Column,
      TGridDrawState State)

    iRowIndex = Grid->DataSource->DataSet->RecNo; // this is always -1


    if (iRowIndex % 2 == 0)
        Grid->Canvas->Brush->Color = clTeal;
    else if (State.Contains(odSelected))
        Grid->Canvas->Brush->Color = clHighlight;
    Grid->Canvas->TextOut(Rect.Left + 1, Rect.Top + 1,



How can I access the valid RecNo ?



Re:TDBGrid->DataSet->RecNo is always -1

> I have a little form with one DBGrid, I want to fill all 2nd row in the

You might try asking this in the database.desktop group.

| Jonathan Arnold (     |
| Havas Interactive             HyperStudio Engineer |
| |

The optimist proclaims we live in the best of all possible
worlds, the pessimist fears this is true. - James Branch Cabell

Other Threads