首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

grid 行颜色交替显示解决办法

2012-02-29 
grid 行颜色交替显示 - C++ Builder / Windows SDK/API大家好:grid控件如何能实现行颜色交替显示呀?比如奇

grid 行颜色交替显示 - C++ Builder / Windows SDK/API
大家好:
  grid控件如何能实现行颜色交替显示呀?比如奇数行背景是白色、偶数行背景色是黄色。

[解决办法]

C/C++ code
void __fastcall TForm1::DBGridEh1DrawDataCell(TObject *Sender,const TRect &Rect, TField *Field, Gridseh::TGridDrawState State){  if(Field->DataSet->RecNo%2 == 0 )    DBGridEh1->Canvas->Brush->Color = clCream;  else     DBGridEh1->Canvas->Brush->Color = clWindow;    DBGridEh1->DefaultDrawDataCell(Rect, Field, State); }
[解决办法]
C/C++ code
void __fastcall TForm1::DBGridEh1DrawDataCell(TObject *Sender,const TRect &Rect, TField *Field, Gridseh::TGridDrawState State){  //选中单元不同颜色  if(State.Contains(gdSelected) || State.Contains(gdFocused))     DBGridEh1->Canvas->Font->Color = clBlue;  else    DBGridEh1->Canvas->Font->Color = clBlack;  DBGridEh1->DefaultDrawDataCell(Rect, Field, State); } 

热点排行