我在使用stringgrid时,发现它的行列不便于增减和刷新,请各位推荐一个更好的。 不能这么说,StringGrid有Rows和Cols属性,插入、删除都很方便的。 procedure GridDeleteRow(RowNumber: Integer; Grid: TstringGrid); var i: Integer; begin Grid.Row := RowNumber; if (Grid.Row = Grid.RowCount - 1) then { On the last row} Grid.RowCount := Grid.RowCount - 1 else begin { Not the last row} for i := RowNumber to Grid.RowCount - 1 do Grid.Rows[i] := Grid.Rows[i + 1]; Grid.RowCount := Grid.RowCount - 1; end; end; 插入类似,你自己写吧
自己写点代码,不管什么功能都挺容易实现的,本人是很讨厌找第三方控件。本人也只能算菜鸟,只是在表格的交互上没有一个控件让人满意的,基本上都还是跟stringgrid没区别。至于显示处理上,功能再多也没什么意思,用OnDrawCell自己实现更简单更灵活。
不能这么说,StringGrid有Rows和Cols属性,插入、删除都很方便的。
procedure GridDeleteRow(RowNumber: Integer; Grid: TstringGrid);
var
i: Integer;
begin
Grid.Row := RowNumber;
if (Grid.Row = Grid.RowCount - 1) then
{ On the last row}
Grid.RowCount := Grid.RowCount - 1
else
begin
{ Not the last row}
for i := RowNumber to Grid.RowCount - 1 do
Grid.Rows[i] := Grid.Rows[i + 1];
Grid.RowCount := Grid.RowCount - 1;
end;
end;
插入类似,你自己写吧
极耗资源,速度可能是Delphi自带的TDBGRID慢慢慢慢三倍以上。
其代码有很多不完善的地方。
最好是自已在原控件上增加方法事件等。不要用什么第三方控件。