改变DBGrid的颜色

2008-02-23 05:38:56来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
{
if(Column->Field->DataSet->RecNo%2)
{
DBGrid1->Canvas->Brush->Color=clSkyBlue;
DBGrid1->Canvas->FillRect(Rect);
}
DrawText(DBGrid1->Canvas->Handle, Column->Field->Text.c_str(),-1,(RECT*)&Rect,DT_SINGLELINE | DT_VCENTER |DT_CENTER);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
for(int i=0;i<DBGrid1->Columns->Count;i )
{ if(i%2==0)DBGrid1->Columns->Items[i]->Color=clAqua;
else DBGrid1->Columns->Items[i]->Color=clInfoBk;
}
}
//-----------------------------------------------------------------




标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇: 用TreeView浏览目录

下一篇: C 对象的放置

热门词条
热门标签