简体   繁体   中英

How to get cell value from specific column/row in a FireMonkey TGrid

Im trying to get value from specific cell from my TGrid but without success. I have try something like this

//Here i get value with a success but i need to get value from first column and 
  no matter what row it is clicked 

TForm1.Grid1GetValue(Sender: TObject; const ACol,ARow: Integer; var Value: TValue);  
begin
             if grid1.Selected <> -1 then
                x:= Value.ToString
end;

For example i clicked on third row.. i need value from first column third row cell. How can i do that?

If you read the documentation for the OnGetValue event, it says:

Occurs when the grid needs to retrieve a value from an external repository to use as the content of one of the cells in this grid.

Write an OnGetValue event handler to take specific actions when you retrieve a value from an external repository to use as the content of one of the cells in this grid.

This is when you are using the grid in a virtual-type mode, storing your data outside of the grid (in an array, a database, etc). TGrid by itself does not store any data. You would use the provided ACol and ARow values to access your own data storage as needed.

If you want to store data in the grid itself, use a TStringGrid instead, which has a Cells property for storing strings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM