請較一個convert的問題 |
答題得分者是:hagar
|
hslin
一般會員 發表:7 回覆:5 積分:2 註冊:2003-10-15 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
Showing Memo Fields in a DbGrid: http://www.q3.nu/trucomania/truco.cgi?354&ing
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); var Grid : TStringGrid; Texto : String; Rectangulo : TRect; begin Rectangulo:=Rect; Grid := TStringGrid(Sender); if Field.IsBlob then begin Grid.Canvas.FillRect(Rect); Texto := Field.AsString; DrawText( Grid.Canvas.Handle, PChar(Texto), StrLen(PChar(Texto)), Rectangulo, DT_WORDBREAK); end; end;How to display memo fields in a TDBGrid: http://www.lmc-mediaagentur.de/dpool/tips/0454.htm procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); var P: array [0..50] of char; {array size is number of characters needed} BS: tBlobStream; {from the memo field} S: String; begin if Field is TMemoField then begin with (Sender as TDBGrid).Canvas do begin BS:= tBlobStream.Create(TBlobField(Field), bmRead); FillChar(P, SizeOf(P), #0); {terminate the null string} BS.Read(P, 50); {read 50 chars from memo into blobStream} BS.Free; S:= StrPas(P); while Pos(#13, S) > 0 do S[Pos(#13, S)] := ' '; while Pos(#10, S) > 0 do S[Pos(#10, S)] := ' '; FillRect(Rect); {clear the cell} TextOut(Rect.Left, Rect.Top, S); {fill cell with memo data} end; end; end;--- Everything I say is a lie. |
hslin
一般會員 發表:7 回覆:5 積分:2 註冊:2003-10-15 發送簡訊給我 |
|
leo2568
中階會員 發表:54 回覆:124 積分:70 註冊:2003-09-21 發送簡訊給我 |
|
hslin
一般會員 發表:7 回覆:5 積分:2 註冊:2003-10-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |