0

如何将列放入 FireMonkey TListBox,然后从 TListBox 的行的列中获取值。我正在使用这种方法:

vListRow := 'Col1Stuff' + '^I' + 'Col2Stuff';

这不是给我第一列中的 Col1Stuff 和第二列中的 Col2Stuff。

我尝试使用 TStringGrid Firemonkey 控件作为替代方法,但以下方法也不起作用:

vStringGrid.Cells[0,1] := '嗨'; vStringGrid.Cells[0,2] := '那里';

这在 TStringGrid 中没有任何内容。

有小费吗?

4

1 回答 1

4

对于TListBox,使用制表符(#9):

ListBox1.Items.Add('Column A' + #9 + 'Column B');

要取出这些值,您必须将它们解析出来,使用制表符作为分隔符(分隔符)。但是,使用 ItemIndex 通常更有效且更易读。

由于您正在进行直接连接,您甚至可以省略“+”(但您还必须删除前导和尾随空格:

ListBox1.Items.Add('Column A'#9'Column B');

对于TStringGrid,使用项目编辑器将两个添加TStringColumns到网格中。然后,您可以访问该Cells属性以读取/写入值 - 请注意Cells由 [column, row] 值引用:

StringGrid1.Cells[0, 1] := 'Column A';   // Column 0, Row 1
StringGrid1.Cells[1, 1] := 'Column B';   // Column 1, Row 1
于 2014-06-12T23:18:03.393 回答