請問一下,TStringGrid的Hint,如何動態顯示欄位內容? |
答題得分者是:ccchen
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
1.Set hint for cells of StringGrid:
http://greatis.com/delphi/components-strgridhint.html
2.How to control the hint position:
http://www.lmc-mediaagentur.de/dpool/tips/0279.htm
3.How to show different hints in a TStringGrid at runtime:
http://www.lmc-mediaagentur.de/dpool/tips/0212.htm ---
Have you ever wondered what it would be like?
|
ccchen
版主 發表:61 回覆:940 積分:1394 註冊:2002-04-15 發送簡訊給我 |
procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var gid: TGridCoord; p1:TPoint; begin gid := StringGrid1.MouseCoord(x,y); //StringGrid中之cell位置 hint:=StringGrid1.Cells[gid.x,gid.y]; //改變hint為cell之內容 p1:=StringGrid1.ClientToScreen(Point(x,y));//將傳入之coordinate換算成Screen Coordinate application.ActivateHint(p1); //主動show hint end;Note:1. 由於StringGrid中所有cell均是同一control,在cell間移動並不會驅動hin故須用ActivateHint 2. 如此做法使hint永遠顯示, 如果不滿意可以用一變數保存目前cell之id, 只在cell改變時才ActivateHint 發表人 - ccchen 於 2003/03/05 09:38:10 |
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
謝謝ccchen版主大大幫忙!我完成的程式碼如下:
procedure TForm1.StrGrdMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var gid: TGridCoord;
p1:TPoint;
begin
gid := StrGrd.MouseCoord(x,y); //StringGrid中之cell位置
if (gid.x>=0) and (gid.x<=StrGrd.colcount) and (gid.y>=0) and (gid.y<=StrGrd.RowCount)then
begin
hint:=StrGrd.Cells[gid.x,gid.y]; //改變hint為cell之內容
p1:=StrGrd.ClientToScreen(Point(x,y));//將傳入之coordinate換算成Screen Coordinate
application.ActivateHint(p1); //主動show hintend;
end;
end; 發表人 - qoo1234 於 2003/03/05 14:58:21
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |