![]() |
#1
|
|||
|
|||
![]()
Hi Guys,
I am trying to see if anyone has an example how to capture a content of the single cell from a datagrid with the mouse click and store into the variable. thanks, Chris |
#2
|
|||
|
|||
![]()
maybe this can ba a way to start:
Retrieve cell values of a TDBGrid using MouseCoord type THackDbGrid = class(TDBGrid); procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var gc: TGridCoord; dbg: TDBGrid; SavedActiveRec: integer; begin dbg := TDBGrid(Sender); gc := dbg.MouseCoord(X, Y); if (gc.X > 0) and (gc.X < dbg.Columns.Count) and (gc.Y > 0) then begin SavedActiveRec := THackDbGrid(Dbg).DataLink.ActiveRecord; THackDbGrid(Dbg).DataLink.ActiveRecord := gc.Y - 1; Dbg.Hint := dbg.Columns[gc.X - 1].Field.AsString; THackDbGrid(Dbg).DataLink.ActiveRecord := SavedActiveRec; end else Dbg.Hint := ''; end; Please click accept if this helps |
#3
|
|||
|
|||
![]()
Use "OnCellClick" event of the DBGrid. Example:
[DELPHI]procedure TForm1.DBGrid1CellClick(Column: TColumn); begin Showmessage( Column.Field.Value ); end;[/DELPHI] Regards, Abdulaziz Jasser |
#4
|
|||
|
|||
![]()
Looking for an answer to this myself.
This only half worked... Showmessage( Column.Field.Value ); ( Modified to Showmessage( Column.Field.AsString); because I want all values displayed as strings.) It only displays the contents of the selected cell in Column zero No matter where on the grid I click. Right Field, Right Row, but always column zero.... WHY? Please??????? Jerbear |
![]() |
Thread Tools | |
Display Modes | |
|
|