找回密碼 或 安全提問
 註冊
|註冊|登錄

伊莉討論區

搜索
尊貴會員無限看帖不用回覆儲值後自動升級用戶組認識好友、聊天,分享生活趣事
julia偷拍fate名偵探柯中文高中kkbox
派遣gebf 711island omacoto a無修cemd 312小鳩ひよ

休閒聊天興趣交流學術文化旅遊交流飲食交流家庭事務PC GAMETV GAME
熱門線上其他線上感情感性寵物交流家族門派動漫交流貼圖分享BL/GL
音樂世界影視娛樂女性頻道潮流資訊BT下載區GB下載區下載分享短片
電腦資訊數碼產品手機交流交易廣場網站事務長篇小說體育運動時事經濟
上班一族博彩娛樂

[繁]無職轉生 第二季1

(4月新番)[簡]被稱為

[簡]Unnamed Memory

[繁]為美好的世界獻上

[繁]迷宮飯16-

[繁]魔王學院的不適任
C & C++ 語言C# 語言Visual Basic 語言PHP 語言JAVA 語言
查看: 949|回復: 1
打印上一主題下一主題

[問題]C++Builder點擊變色!!急需請高手解答[複製鏈接]

帖子
0
積分
0 點
潛水值
40 米
跳轉到指定樓層
樓主
發表於 2009-9-7 10:54 AM|只看該作者|倒序瀏覽
若新密碼無法使用,可能是數據未更新。請使用舊密碼看看。
本帖最後由 luckbox520 於 2009-9-7 10:59 AM 編輯

請高手大大們幫忙解答

我的問題是:

我在BCB中做了一個表格

這個大表格內每格都有數據

如何當我滑鼠點擊(左鍵單擊)任一格時

該格字體變為紅色

點別格後又還原成原本顏色(黑色)
分享分享0收藏收藏0支持支持0
成為伊莉的版主,你將獲得更高級和無限的權限。把你感興趣的版面一步步地發展和豐盛,那種滿足感等著你來嚐嚐喔。

使用道具檢舉

teldeanmac85 該用戶已被刪除
頭香
發表於 2009-9-8 09:12 AM|只看該作者
試看看!!應該OK~
  1. //---------------------------------------------------------------------------

  2. #ifndef Unit1H
  3. #define Unit1H
  4. //---------------------------------------------------------------------------
  5. #include <Classes.hpp>
  6. #include <Controls.hpp>
  7. #include <StdCtrls.hpp>
  8. #include <Forms.hpp>
  9. #include <Grids.hpp>
  10. //---------------------------------------------------------------------------
  11. class TForm1 : public TForm
  12. {
  13. __published:        // IDE-managed Components
  14.         TStringGrid *StringGrid1;
  15.         void __fastcall StringGrid1MouseDown(TObject *Sender,
  16.           TMouseButton Button, TShiftState Shift, int X, int Y);
  17.         void __fastcall StringGrid1DrawCell(TObject *Sender, int ACol,
  18.           int ARow, TRect &Rect, TGridDrawState State);
  19. private:        // User declarations
  20. public:                // User declarations
  21.         __fastcall TForm1(TComponent* Owner);

  22.         void __fastcall SetSGPos(int Col,int Row);
  23.         void __fastcall GetSGPos(int *Col,int *Row);
  24.         int m_ACol ;
  25.         int m_ARow ;
  26. };
  27. //---------------------------------------------------------------------------
  28. extern PACKAGE TForm1 *Form1;
  29. //---------------------------------------------------------------------------
  30. #endif


  31. //---------------------------------------------------------------------------

  32. #include <vcl.h>
  33. #pragma hdrstop

  34. #include "Unit1.h"
  35. //---------------------------------------------------------------------------
  36. #pragma package(smart_init)
  37. #pragma resource "*.dfm"
  38. TForm1 *Form1;
  39. //---------------------------------------------------------------------------
  40. __fastcall TForm1::TForm1(TComponent* Owner)
  41.         : TForm(Owner)
  42. {
  43.    for(int x=1;x<StringGrid1->ColCount;x++){
  44.       for(int y=1;y<StringGrid1->RowCount;y++){
  45.          StringGrid1->Cells[x][y] = "TEST" ;
  46.       }
  47.    }
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TForm1::SetSGPos(int Col,int Row)
  51. {
  52.    m_ACol = Col ;
  53.    m_ARow = Row ;
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TForm1::GetSGPos(int *Col,int *Row)
  57. {
  58.    *Col = m_ACol  ;
  59.    *Row = m_ARow  ;
  60. }

  61. //---------------------------------------------------------------------------

  62. void __fastcall TForm1::StringGrid1MouseDown(TObject *Sender,
  63.       TMouseButton Button, TShiftState Shift, int X, int Y)
  64. {
  65.    if( Button == mbLeft ){
  66.       SetSGPos(StringGrid1->Col,StringGrid1->Row);
  67.       StringGrid1->Repaint() ;
  68.    }
  69. }
  70. //--------------------------------------------------------------------------
  71. void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
  72.       int ARow, TRect &Rect, TGridDrawState State)
  73. {
  74.     int Col = 0 , Row = 0 ;

  75.     GetSGPos( &Col , &Row ) ;

  76.     if (State.Contains(gdFixed)) return;

  77.     if (ARow==Row && ACol == Col){
  78.        StringGrid1->Canvas->Font->Color=clRed ;
  79.     }
  80.     else{
  81.        StringGrid1->Canvas->Font->Color=clBlack ;
  82.     }

  83.     StringGrid1->Canvas->TextRect (Rect, Rect.Left, Rect.Top,StringGrid1->Cells[ACol][ARow]);

  84. }
  85. //---------------------------------------------------------------------------
複製代碼
...
瀏覽完整內容,請先 註冊登入會員
如果瀏覽伊莉時速度太慢或無法連接,可以使用其他分流瀏覽伊莉,www01.eyny.com(02,03)。

使用道具檢舉

您需要登錄後才可以回帖 登錄 | 註冊

Powered by Discuz!

© Comsenz Inc.

重要聲明:本討論區是以即時上載留言的方式運作,對所有留言的真實性、完整性及立場等,不負任何法律責任。而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。於有關情形下,用戶應尋求專業意見(如涉及醫療、法律或投資等問題)。 由於本討論區受到「即時上載留言」運作方式所規限,故不能完全監察所有留言,若讀者發現有留言出現問題,請聯絡我們。有權刪除任何留言及拒絕任何人士上載留言,同時亦有不刪除留言的權利。切勿上傳和撰寫 侵犯版權(未經授權)、粗言穢語、誹謗、渲染色情暴力或人身攻擊的言論,敬請自律。本網站保留一切法律權利。
回頂部