<b>改变DBGrid的颜色</b>[VC/C++编程]
本文“<b>改变DBGrid的颜色</b>[VC/C++编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
//---------------------------------------------------------------------------
#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;
}
}
//---------------------------------------------------------------------------
以上是“<b>改变DBGrid的颜色</b>[VC/C++编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |