StringGrid |
尚未結案
|
jason_cyl329
高階會員 ![]() ![]() ![]() ![]() 發表:123 回覆:155 積分:105 註冊:2003-05-26 發送簡訊給我 |
|
m8815010
版主 ![]() ![]() ![]() ![]() ![]() 發表:99 回覆:372 積分:289 註冊:2003-11-13 發送簡訊給我 |
引言: 請問, 使用TStringGrid,假設有很多的格子,游標還在最上端,使用ScrollBar拉到最底端,這時在用滾輪往下移動,畫面又會由原來的游標處開始往下移動,請問要如何防止這種狀況?我需要的是已經到最下端,就應該以此位址開始來做移動的變化!!jason_cyl329你好 In Unit1.cpp ~~ TForm1 *Form1; int i=0; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { OldStringGridWndProc=StringGrid1->WindowProc; StringGrid1->WindowProc=StringGridWndProc; } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { StringGrid1->RowCount=50; StringGrid1->ColCount=15; for (int i=0;i<15;i ) { for (int j=0;j<50;j ) StringGrid1->Cells[i][j]="(" IntToStr(i) "," IntToStr(j) ")"; } } //--------------------------------------------------------------------------- void __fastcall TForm1::StringGridWndProc(TMessage& Message) { if (Message.Msg==WM_VSCROLL) { if (LOWORD(Message.WParam)==SB_ENDSCROLL) { i ; this->Caption=i; TGridRect myRect; myRect.Left = 1; myRect.Top = StringGrid1->TopRow; myRect.Right = 1; myRect.Bottom = StringGrid1->TopRow; StringGrid1->Selection = myRect; //StringGrid1->SetFocus(); } } OldStringGridWndProc(Message); }精神就是每次使用Scroo bar操作完後,自動將focus的cell設在本頁的最上最左一格cell,這樣就比較有同步的感覺了< >! 注意: >! 以上,參著參著< >! |
jason_cyl329
高階會員 ![]() ![]() ![]() ![]() 發表:123 回覆:155 積分:105 註冊:2003-05-26 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |