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
drid
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
!!!!!

    Grid->Canvas->FillRect(Rect);

    if (iRowIndex % 2 == 0)
    {
        Grid->Canvas->Brush->Color = clTeal;
        Grid->Canvas->FillRect(Rect);
    }
    else if (State.Contains(odSelected))
    {
        Grid->Canvas->Brush->Color = clHighlight;
    }
    Grid->Canvas->TextOut(Rect.Left + 1, Rect.Top + 1,
Grid->Fields[DataCol]->AsString);

Quote
}

*/

How can I access the valid RecNo ?

Greetings,
Andrs

 

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


Quote
> 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 (mailto:jdarn...@buddydog.org)     |
| Havas Interactive             HyperStudio Engineer |
| http://www.buddydog.org http://www.hyperstudio.com |
+====================================================+

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

Other Threads