K kuux Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-16 #1 我在strgrid中寫了幾個列,其中一部分,是名字等字符型數據,要左對齊, 還一部分,是金額等數值型數據,要右對齊,請問應如何實現呀?
H hi.jack Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-17 #3 在StringGrid的DrawCell事件中添加类似的代码就可以了: VAR vCol, vRow : LongInt; begin vCol := ACol; vRow := ARow; WITH Sender AS TStringGrid, Canvas DO IF vCol = 2 THEN BEGIN ///对于第2列设置为右对齐 SetTextAlign(Handle, TA_RIGHT); FillRect(Rect); TextRect(Rect, Rect.RIGHT-2, Rect.Top+2, Cells[vCol, vRow]); END; end;
在StringGrid的DrawCell事件中添加类似的代码就可以了: VAR vCol, vRow : LongInt; begin vCol := ACol; vRow := ARow; WITH Sender AS TStringGrid, Canvas DO IF vCol = 2 THEN BEGIN ///对于第2列设置为右对齐 SetTextAlign(Handle, TA_RIGHT); FillRect(Rect); TextRect(Rect, Rect.RIGHT-2, Rect.Top+2, Cells[vCol, vRow]); END; end;
K kuux Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-17 #4 to hi.jack: 你的程序第二列是靠右了,可其它列的數據可就都沒有了呀