gpt4 book ai didi

delphi - 如何从 TcxGrid 获取选定的单元格文本?

转载 作者:行者123 更新时间:2023-12-02 14:44:38 25 4
gpt4 key购买 nike

我正在使用 Devexpress TcxGrid,并且正在尝试获取选定的单元格文本。我的 TcxGrid 连接到某种数据源 - 我认为它是 DataControler。

我的目标是从整行的单元格中获取文本并将其放入用逗号分隔的字符串中。

最佳答案

如果您想要多选值和来自 TcxGridDbTableView 的值:在我的结果中,行之间没有分隔。

function GetSelectedValuesFrmGrid: String;
var
intSelectLoop,
intRowLoop: Integer;
oTableView: TcxGridDbTableView;
strValue: Variant;
oList: TStringList;
begin
Result:= '';
// Kind Of TableView
if <TcxGrid>.ActiveView is TcxGridDbTableView then
begin
oTableView:= <TcxGrid>.ActiveView as TcxGridDbTableView;
oList:= TStringList.Create();
try
for intSelectLoop:= 0 to oTableView.Controller.SelectedRowCount-1 do
begin
for intRowLoop:= 0 to oTableView.Controller.SelectedRows[intSelectLoop].ValueCount-1 do
begin
strValue:= oTableView.Controller.SelectedRows[intSelectLoop].Values[intRowLoop];
// Value can be Null
if VarIsNull(strValue) then
begin
strValue:= '';
end;
oList.Add(strValue);
end;
end;
Result:= oList.CommaText;
finally
oList.Free;
end;
end;
end;

关于delphi - 如何从 TcxGrid 获取选定的单元格文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9872846/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com