Re: Active row in DBGrid?

From: cOOl (coolman_kk_at_yahoo.com)
Date: 11/26/03


Date: Wed, 26 Nov 2003 19:16:23 +0200


> That code (on my system) displays the hint no matter what cell the
> mouse is over, not just the highlighted cell. However, the hint shown
> is always from the selected (highlighted) row of the grid. If you were
> hoping to get the cell and row over which the mouse is at that point,
> you will have to do some digging through the VCL code, particularly
> TCustomGrid.CalcCoordFromPoint, to see how to calculate the row and
> column numbers. The column should not be too hard because the Columns
> property will give you the width of each column, but there is no
> equivalent for the row heights.

Thank you
Source below work.

I have only one question for DBGrid.
How to change data in Grid before show it?
I have table:
    C_IME CHAR(20),N_PRICE CHAR(7,2)

Grid show this data for table:

    test1 1
    test2 1,2
    test3 1,33
    test4 2,3

how to change format of N_PRICE like this:

    test1 1,00
    test2 1,20
    test3 1,33
    test4 2,30

Thank you.

-------------------------------
var
  nSaveGridRow: Integer;

procedure TForm9.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  If gdSelected in State Then nSaveGridRow := Rect.Top;
end;

procedure TForm9.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  pt: TGridcoord;
begin
  pt := DBGrid1.MouseCoord( x,y );

  If ( ( pt.Y * 18 ) = nSaveGridRow ) And Not ( Form9.IBQuery1.IsEmpty )
Then Begin
    DBGrid1.ShowHint := True;
    DBGrid1.Hint := Format( 'Date created: %s' + #13 + 'Last update: %s',
      [FormatDateTime( 'dddd, dd mmmm yyyy
[hh:mm:ss]',DBGrid1.DataSource.DataSet.FieldValues['D_CREATE'] ),
      FormatDateTime( 'dddd, dd mmmm yyyy
[hh:mm:ss]',DBGrid1.DataSource.DataSet.FieldValues['D_UPDATE'] )] );
  End Else Begin
    DBGrid1.ShowHint := False;
    DBGrid1.Hint := '';
  End;
end;



Relevant Pages

  • Re: Grid and Array Association
    ... When all the calculations are completed, you want to put the total ... count for each date in the cell just below that date. ... Loop through GridArray assigning the date found at the top of the grid ... called dResult. ...
    (microsoft.public.vb.general.discussion)
  • Re: Grid and Array Association
    ... When all the calculations are completed, you want to put the total ... count for each date in the cell just below that date. ... Loop through GridArray assigning the date found at the top of the grid ... called dResult. ...
    (microsoft.public.vb.general.discussion)
  • RE: Help with developing sudoku gui using GDI+
    ... x/y mouse coordinates to indices in your array. ... Let's assume that your grid ... information like the number that is already filled in on the cell. ... the selected rectangle. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Grid and Array Association
    ... When all the calculations are completed, you want to put the total ... count for each date in the cell just below that date. ... Loop through GridArray assigning the date found at the top of the grid ... called dResult. ...
    (microsoft.public.vb.general.discussion)
  • Re: Grid and Array Association
    ... When all the calculations are completed, you want to put the total ... count for each date in the cell just below that date. ... Loop through GridArray assigning the date found at the top of the grid ... called dResult. ...
    (microsoft.public.vb.general.discussion)