|
如何合并stringgrid的單元格,在合并格子里輸入文字能居中 在Delphi中,如何合并stringgrid的單元格,在合并格子里輸入文字能居中。不是效果上的,而是可以打印出來的。最好給出相關(guān)的代碼,萬分感謝!
------解決方案-------------------- StringGrid不能真正的合并單元格 只能自己畫 例子: 合并第三行第二、三兩格 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方控件 ------解決方案-------------------- 如果你想做這個,不要用StringGrid,不如用DrawGrid,可能更靈活一些 ------解決方案-------------------- 哈哈,有現(xiàn)成的東西 xlgrid 并且有全套代碼 |
|
|