本文整理自网络,侵删。

procedure TForm1.sEdit1Change(Sender: TObject);procedure TForm1.sEdit1Change(Sender: TObject);var i: integer; str: string; c: char; arr: array[0..200, 0..200] of string; A, j: integer;begin str := sedit1.text; for i := 0 to length(str) do begin c := str[i]; //ShowMessage(c); arr[0][0] := '分解后字符串'; arr[1][0] := '索引'; arr[2][0] := '切片时索引'; StringGrid1.RowCount := 3; //这个是行数 StringGrid1.ColCount := i + 2; //这个是列数 (列数+1才对啊) StringGrid1.ColWidths[0] := 0; StringGrid1.ColWidths[1] := 130; arr[0][i] := c; //这个是分解后的单个字符中的第1行 arr[1][i] := IntToStr(i - 1); //这个是分解后对应的索引,也就是第2行 arr[2][i] := '-' + IntToStr(length(str) - i + 1);
end;//ShowMessage(IntToStr(i - 1)); for A := Low(arr) to High(arr) do //这个是调整表格,隐藏第一列的! for j := Low(arr[A]) + 1 to High(arr[A]) + 1 do begin StringGrid1.Cells[j, A] := arr[A][j - 1] end;end;
来源:https://www.52pojie.cn/thread-1296701-1-1.html
相关阅读 >>
Delphi windows 编程[10] - wm_lbuttondown、wm_lbuttonup 和 wm_mousemove 消息
Delphi xe6开发的android应用实现在线升级完成后自动安装apk代码
Delphi利用getprocessmemoryinfo获取进程占用内存大小
Delphixe4 版本中,已针对移动平台 引入了 arc 模型
更多相关阅读请进入《Delphi》频道 >>