[英]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.我试图从我的 TGrid 的特定单元格中获取价值,但没有成功。 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:如果您阅读
OnGetValue
事件的文档,它会说:
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.
编写 OnGetValue 事件处理程序以在您从外部存储库检索值以用作此网格中的一个单元格的内容时采取特定操作。
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. TGrid
本身不存储任何数据。 You would use the provided ACol
and ARow
values to access your own data storage as needed.您可以根据需要使用提供的
ACol
和ARow
值来访问您自己的数据存储。
If you want to store data in the grid itself, use a TStringGrid
instead, which has a Cells
property for storing strings.如果您想在网格本身中存储数据,请改用
TStringGrid
,它具有用于存储字符串的Cells
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.