Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何访问TStringGrid中的字符?_String_Delphi_Datagrid - Fatal编程技术网

如何访问TStringGrid中的字符?

如何访问TStringGrid中的字符?,string,delphi,datagrid,String,Delphi,Datagrid,如何在Delphi中从TStringGrid获取字符 StringGrid1.Cells[X, Y, Z]//doesn't work StringGrid1.Cells[X][Y][Z]//doesn't work 您知道StringGrid1.Cells[X,Y]是一个字符串,包含单元格中的文本,坐标为X,Y。您还知道,如果S是字符串,则S[n]是S的n第个字符。结合这些知识,你会意识到 StringGrid1.Cells[X, Y][n] 是坐标为X,Y的单元格中的n第个字符。但是要注

如何在Delphi中从TStringGrid获取字符

StringGrid1.Cells[X, Y, Z]//doesn't work
StringGrid1.Cells[X][Y][Z]//doesn't work

您知道
StringGrid1.Cells[X,Y]
是一个
字符串
,包含单元格中的文本,坐标为
X,Y
。您还知道,如果
S
字符串,则
S[n]
S
n
第个字符。结合这些知识,你会意识到

StringGrid1.Cells[X, Y][n]
是坐标为
X,Y
的单元格中的
n
第个字符。但是要注意:单元格坐标是基于0的,字符索引是基于1的。因此,例如,左上角单元格中的第一个字符是

StringGrid1.Cells[0, 0][1]

如果此单元格确实包含至少一个字符的字符串。

StringGrid1.Cells[X,Y][Z]
@TLama:这不是注释;这是一个答案。嗯。。。在俄罗斯,这将被称为炮兵叉;-)谢谢,我尝试过这个方法,所以我认为字符串的第一个元素没有被索引为0有问题。