我的表单上有一个保存按钮,它循环遍历tcxgrid的所有行并读取它的值。我正在尝试读取其中一列中的组合框的值,但我需要读取键值,而不是它的文本。
for I := 0 to tv.DataController.RecordCount - 1 do
begin
Location := tv.DataController.Values[I, colLocation.Index];
end;colLocation是组合框,但是这样做会给出所选的文本,而不是ItemIndex值。有什么线索吗?
谢谢
发布于 2016-12-09 18:42:19
如果您询问如何在当前网格行的ComboBox项属性中获取数字索引,则可以使用如下代码进行此操作
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;如果这不能回答你的问题,你最好解释清楚你想要什么。
https://stackoverflow.com/questions/41065581
复制相似问题