怎么设置dbgrideh的字段和字体颜色
1个回答
展开全部
重载grideh的OnDBGridEh1DrawColumnCell事件
void __fastcall TFrmMain::OnDBGridEh1DrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumnEh *Column,
Gridseh::TGridDrawState State)
{
TDataSet *pDS;
pDS = this->DBGridEh1->DataSource->DataSet;
if( pDS->Active && pDS->RecordCount > 0 )
{
if( pDS->RecNo %2 == 0 && !State.Contains( Gridseh:: gdSelected) )
{
((TDBGrid*)Sender)->Canvas->Brush->Color = RGB(228,241,226);//定义背景颜色
((TDBGrid*)Sender)->Canvas->Font->Color = RGB(0,0,255);//字体颜色
((TDBGrid*)Sender)->Canvas->Font->Style = TFontStyles()<< fsBold ;
}
((TDBGridEh*)Sender)->DefaultDrawColumnCell(Rect, DataCol, Column, State);
}
}
void __fastcall TFrmMain::OnDBGridEh1DrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumnEh *Column,
Gridseh::TGridDrawState State)
{
TDataSet *pDS;
pDS = this->DBGridEh1->DataSource->DataSet;
if( pDS->Active && pDS->RecordCount > 0 )
{
if( pDS->RecNo %2 == 0 && !State.Contains( Gridseh:: gdSelected) )
{
((TDBGrid*)Sender)->Canvas->Brush->Color = RGB(228,241,226);//定义背景颜色
((TDBGrid*)Sender)->Canvas->Font->Color = RGB(0,0,255);//字体颜色
((TDBGrid*)Sender)->Canvas->Font->Style = TFontStyles()<< fsBold ;
}
((TDBGridEh*)Sender)->DefaultDrawColumnCell(Rect, DataCol, Column, State);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询