首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >循环TcxEditRepositoryComboBoxItem时如何访问cxGrid中的选定项?

循环TcxEditRepositoryComboBoxItem时如何访问cxGrid中的选定项?
EN

Stack Overflow用户
提问于 2016-12-09 17:14:06
回答 1查看 1.7K关注 0票数 1

我的表单上有一个保存按钮,它循环遍历tcxgrid的所有行并读取它的值。我正在尝试读取其中一列中的组合框的值,但我需要读取键值,而不是它的文本。

代码语言:javascript
复制
for I := 0 to tv.DataController.RecordCount - 1 do
begin
  Location := tv.DataController.Values[I, colLocation.Index];
end;

colLocation是组合框,但是这样做会给出所选的文本,而不是ItemIndex值。有什么线索吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-09 18:42:19

如果您询问如何在当前网格行的ComboBox项属性中获取数字索引,则可以使用如下代码进行此操作

代码语言:javascript
复制
procedure TForm1.ProcessComboBox;
var
  I,
  Index : Integer;
  S : String;
  V : OleVariant;
begin
  for I := 0 to tv.DataController.RecordCount - 1 do
  begin
    V := tv.DataController.Values[I, colLocation.Index];
    S := V;
    //  if the RepositoryItem of colLocation is set to cxEditRepository1ComboBoxItem1
    //  you can do
    Index := cxEditRepository1ComboBoxItem1.Properties.Items.IndexOf(S);

    //  OR, if the Properties property of colLocation is set to ComboBox you could do
    //  Index := TcxComboBoxProperties(colLocation.Properties).Items.IndexOf(S);

    S := IntToStr(Index);
    Caption := S;
  end;
end;

如果这不能回答你的问题,你最好解释清楚你想要什么。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41065581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档