Stringgrid中如何对每行设置不同的颜色显示,谢谢帮助!

Ri_syf 2003-03-18 06:11:53
Stringgrid中如何对每行设置不同的颜色显示,谢谢帮助!
...全文
59 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kin_CIOM 2003-03-19
  • 打赏
  • 举报
回复
还不简单吗??
Ri_syf 2003-03-18
  • 打赏
  • 举报
回复
非常感谢!
还有其他简单的方法吗?
lanren_me 2003-03-18
  • 打赏
  • 举报
回复
学习
牧牛人软件 2003-03-18
  • 打赏
  • 举报
回复
上例是两中颜色,要多种的话:
switch (ARow%20){

case 0:ResultStringGrid->Canvas->Brush->Color=(TColor)0x00E6FADC;break;
case 1:..........
case 2:............
.......
}
牧牛人软件 2003-03-18
  • 打赏
  • 举报
回复

void __fastcall TNoteForm::ResultStringGridDrawCell(TObject *Sender,
int ACol, int ARow, TRect &Rect, TGridDrawState State)
{

try
{
if(ARow>=ResultStringGrid->FixedRows && ACol>=ResultStringGrid->FixedCols)
{
ResultStringGrid->Canvas->Font->Color = GetFontColor(ResultStringGrid->Cells[ACol][ARow], ACol,ResultStringGrid->FixedCols);
if(ARow%2 == 0)
{
ResultStringGrid->Canvas->Brush->Color=(TColor)0x00E6FADC;
}
else
{
ResultStringGrid->Canvas->Brush->Color=(TColor)0x00FBEFD5;
}
}
else{
ResultStringGrid->Canvas->Font->Color = clBlack;
ResultStringGrid->Canvas->Brush->Color=(TColor)0x00DDDDDD;
}

ResultStringGrid->Canvas->FillRect(Rect);
DrawText(ResultStringGrid->Canvas->Handle, ResultStringGrid->Cells[ACol][ARow].c_str(), -1, (RECT*)&Rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
}
catch(Exception &exception)
{
Application->ShowException(&exception);
return ;
}

}

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧