關於StringAlignGrid(或 StringGrid )的2個有趣問題? |
尚未結案
|
mathewzhao
中階會員 ![]() ![]() ![]() 發表:121 回覆:164 積分:67 註冊:2003-04-04 發送簡訊給我 |
各位先進好!
在StringAlignGrid(或 StringGrid)中:
Q1:如何可以做到cells合併?
Q2:設定字體的Color,Size,Style等後,再Paste到其他區域時,如何仍能保持字體的Color,Name,Size,Style等。 另有一問題,雖然簡單,但左思右想還不清楚所以請教各位先進:
我將goEditing 設為 false(這樣可以RangeSelect);
在StringAlignGrid1 DblClick 或 KeyDown時,將goEditing 設為 true
這時可以輸入,但在按鍵前cell中沒出現輸入 cursor,請問如何在
cell中顯示輸入 cursor.
|
hagar
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
1.關於合併 cell, 這有一篇:
http://groups.google.com.tw/groups?hl=zh-TW&lr=&ie=UTF-8&oe=UTF-8&selm=VA.00004429.00aa7edf%40petersnewbox
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var i, x, y: Integer; begin If gdFixed In State Then Exit; If ARow > 1 Then Exit; // draw row 1 with text from cell 1,1 spanning all cells in the row with sender as tstringgrid do begin {extend rect to include grid line on right, if not last cell in row} If aCol < Pred(ColCount) Then Rect.Right := Rect.Right GridlineWidth; {figure out where the text of the first cell would start relative to the current cells rect. } y:= Rect.Top 2; x:= Rect.Left 2; for i:= 1 to aCol-1 do x:= x - ColWidths[i] - GridlineWidth; { Paint cell pale yellow} Canvas.Brush.Color := $7FFFFF; Canvas.Brush.Style := bsSolid; Canvas.FillRect( Rect ); { Paint text of cell 1,1 clipped to current cell. } Canvas.TextRect( Rect, x, y, Cells[1,1] ); end; end; procedure TForm1.FormCreate(Sender: TObject); var i, k: Integer; begin with stringgrid1 do begin cells[1, 1] := 'A rather long line which will span cells'; for i:= 1 to colcount-1 do for k:= 2 to rowcount -1 do cells[i,k] := Format('Cell[%d,%d]', [i,k]); end; end;2.在 OnKeyDown 攔截貼上的 Key 3.ShowCursor 行不行? --- --<-<-<@ 發表人 - hagar 於 2003/08/15 20:25:39 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |