StringGrid的格子是否只能塞一行的字而已?! |
尚未結案
|
bonnie.fan
一般會員 ![]() ![]() 發表:6 回覆:1 積分:1 註冊:2003-10-08 發送簡訊給我 |
|
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
jason_cyl329
高階會員 ![]() ![]() ![]() ![]() 發表:123 回覆:155 積分:105 註冊:2003-05-26 發送簡訊給我 |
|
pgdennis
資深會員 ![]() ![]() ![]() ![]() ![]() 發表:41 回覆:526 積分:443 註冊:2002-05-23 發送簡訊給我 |
以前在網路找的,直接co過去用就行了...應該不用改
procedure TFMT3020101.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var StringPart, NumberPart: String; Width,Width2: Integer; {width of the numerical part of our string} LeftOffset: Integer; {Left offset of the right justified text} SecondLine: Integer; {vertical position of line 2 } const Margin = 2; begin //if ARow=1 then begin{只處理title} {extract the first word of the cell's text} StringPart := Copy(StringGrid1.Cells[ACol, ARow], 1, Pos(' ', StringGrid1.Cells[ACol, ARow])-1); {extract the numerical part of the cell's text} NumberPart := Copy(StringGrid1.Cells[ACol, ARow], Length(StringPart) 1, Length(StringGrid1.Cells[ACol, ARow])); {What it the width of the text of the number?} Width := StringGrid1.Canvas.TextWidth(NumberPart); Width2 := StringGrid1.Canvas.TextWidth(StringPart); {Where do we position line 2?} SecondLine := Rect.Top ((Rect.Bottom - Rect.Top) div 2); LeftOffset := Rect.Right - Width - Margin; {blank out the cell} StringGrid1.Canvas.FillRect(Rect); {draw the first line of text (the string part) at the top of the cell} StringGrid1.Canvas.TextOut(Rect.Left 30 Margin, Rect.Top Margin, StringPart); //StringGrid1.Canvas.TextOut(StringGrid1.ColWidths[ACol]-(Width2 div 2), Rect.Top Margin, StringPart); {draw the number part on line 2 but also right justify it} StringGrid1.Canvas.TextOut(LeftOffset, SecondLine, NumberPart); end;永遠追不上技術更新的速度
------
星期一,二...無窮迴圈@@ |
Mickey
版主 ![]() ![]() ![]() ![]() ![]() 發表:77 回覆:1882 積分:1390 註冊:2002-12-11 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |