StringGrid元件的CELL可以改變底色嗎??? |
答題得分者是:supman
|
penny015
一般會員 發表:20 回覆:15 積分:7 註冊:2005-03-25 發送簡訊給我 |
|
supman
尊榮會員 發表:29 回覆:770 積分:924 註冊:2002-04-22 發送簡訊給我 |
您好:
參考以下方式
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { if ((ARow>=1) && (ACol>=1))//標題欄位不改變顏色 { if (StringGrid1->Cells[ACol][ARow]<="10") { StringGrid1->Canvas->Brush->Color=clRed;//改變底色 StringGrid1->Canvas->Font->Color=clBlue;//改變字型顏色 } if (StringGrid1->Cells[ACol][ARow]<="10") { StringGrid1->Canvas->Brush->Color=clBlack; StringGrid1->Canvas->Font->Color=clBlue; } StringGrid1->Canvas->FillRect(Rect);//畫底色 StringGrid1->Canvas->TextOut(Rect.Left 2,Rect.Top 2,StringGrid1->Cells[ACol][ARow]);//畫原來的資料 } } 有問題的話請用站內搜尋 StringGrid 底色,有很多討論主題. |
iii0628
一般會員 發表:50 回覆:46 積分:19 註冊:2005-04-04 發送簡訊給我 |
你好:感謝你的回答,我現在有個問題是如果我程式是寫StringGrid1->Cells[ACol][ARow]>"80",會變成判斷字串所以有80 ,881 ,850,8開頭的整數會判斷出來,像500,400...等就會被判斷成小於80。所以我將str轉成Int在來比較,編譯時會過但是到LINKER的時候就出現is not a valid interger value
,要如何改勒???謝謝
if (StrToInt(StringGrid1->Cells[ACol][ARow])>80) { StringGrid1->Canvas->Brush->Color=clRed;//改變底色 StringGrid1->Canvas->Font->Color=clBlue;//改變字型顏色 } StringGrid1->Canvas->FillRect(Rect);//畫底色 StringGrid1->Canvas->TextOut(Rect.Left 2,Rect.Top 2,StringGrid1->Cells[ACol][ARow]); 引言: 您好: 參考以下方式void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { if ((ARow>=1) && (ACol>=1))//標題欄位不改變顏色 { if (StringGrid1->Cells[ACol][ARow]<="10") { StringGrid1->Canvas->Brush->Color=clRed;//改變底色 StringGrid1->Canvas->Font->Color=clBlue;//改變字型顏色 } if (StringGrid1->Cells[ACol][ARow]<="10") { StringGrid1->Canvas->Brush->Color=clBlack; StringGrid1->Canvas->Font->Color=clBlue; } StringGrid1->Canvas->FillRect(Rect);//畫底色 StringGrid1->Canvas->TextOut(Rect.Left 2,Rect.Top 2,StringGrid1->Cells[ACol][ARow]);//畫原來的資料 } } 有問題的話請用站內搜尋 StringGrid 底色,有很多討論主題. |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |