Board index » delphi » Help with component!!!

Help with component!!!

Hello,

I am having trouble with this component I am writing.  I have this
component I wrote that inherits from TCustomDBGrid.  What it does is in
the first column it draws a checkbox for the user to select which row(s)
they want, with the other columns getting filled with data from the
database(this checkbox field is a dummy field with no database field
connected to it). To keep track of this I have a public array of boolean
values.  This will record whether or not a row is checked.  My problem
arises that the grid doesn't record 'absolute' row numbers only the row
numbers of its relative position on the screen(ie.  it may actually be
the 15th row in the grid but it could be four rows from the top of the
grid so the grid thinks it is row 4 and not 15).  So, what I need is to
be able to keep track of 'absolute' row numbers to set the array
correctly and thereby pull off the correct values from the grid.  Any
suggestions or help would be greatly, greatly appreciated.  Thanks.

Robert
--
+----------------------------------------------------------+
|  Robert Walter           _______                         |
|  Software Engineer         | |  |          _|_      _    |
|  rober...@thentec.com.au   | |  |/| /_\ |\  |  /_\ /     |
|                            |/   | | \_  | | \_ \_  \_    |
|  Phone +61 7 3371 6611     THENTEC GROUP OF COMPANIES    |
|  Fax   +61 7 3371 6633     http://www.thentec.com.au     |
+----------------------------------------------------------+

 

Re:Help with component!!!


Hi, Robert

First you have to make sure that your public row array is big enough, but I
am sure your can handle it yourself.

Now - back to your problem:

I need to be looking at TDateSet component (TQuery, TTable) instead of the
TCustomDBGrid in the on-line help. Here you may find the properties you
need:

  RecordCount
  RecordNo ( - or is it RecNo ?? )
  etc.

You gain access to the TDataSet component from you CheckBoxDBGrid using :

-------

   RecCnt := 0;
   if  CheckBoxDBGrid.DataSource <> nil then
   begin
       RecCnt := CheckBoxDBGrid.DataSource.DataSet.RecordCount;
       CurRec := CheckBoxDBGrid.DataSource.DataSet.RecordNo;
   end;

--------

Greatings

Jesper

SoftCon
j...@post6.tele.dk
www.softcon.dk

Other Threads