如何合并stringgrid的單元格,在合并格子里輸入文字能居中
在Delphi中,如何合并stringgrid的單元格,在合并格子里輸入文字能居中。不是效果上的,而是可以打印出來(lái)的。最好給出相關(guān)的代碼,萬(wàn)分感謝!
------解決方案--------------------
StringGrid不能真正的合并單元格
只能自己畫(huà)
例子:
合并第三行第二、三兩格
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if(ARow = 2) and (ACol = 2) then
begin
Rect.Left := Rect.Left -2;
end;
if(ARow = 2) and (ACol = 1) then
begin
Rect.Right := Rect.Right + 2;
end;
StringGrid1.Canvas.TextRect(Rect, Rect.Left, Rect.Top, StringGrid1.Cells[ACol, ARow]) ;
end;
------解決方案--------------------
StringGrid不是Excel,你要的功能要找第3方控件
------解決方案--------------------
如果你想做這個(gè),不要用StringGrid,不如用DrawGrid,可能更靈活一些
------解決方案--------------------
哈哈,有現(xiàn)成的東西 xlgrid 并且有全套代碼
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。