添加pas文件
EhLibADO.pas
EhLibCDS.pas
EhLibFireDAC.pas
支持FireDAC
设置GridEh的属性
DBGridEh1->SortLocal = true;
DBGridEh1->OptionsEh << dghAutoSortMarking;
DBGridEh1->ColumnDefValues->Title->TitleButton = True;
DBGridEh1.SortLocal := true;
DBGridEh1.OptionsEh := DBGridEh1.OptionsEh + [dghAutoSortMarking];
DBGridEh1.ColumnDefValues.Title.TitleButton := true;
grideh改变单元格字体颜色
void __fastcall TFrm ::DBGridEh2DrawColumnCell(TObject *Sender, const TRect &Rect, int DataCol, TColumnEh *Column, Gridseh::TGridDrawState State) { if (Column->FieldName == "性别" && Column->Field->Value == "009") { DBGridEh2->Canvas->Font->Color = clRed; DBGridEh2->DefaultDrawColumnCell(Rect, DataCol, Column, State); } }
单元格背景
DBGridEh1.Canvas.Brush.Color := clGreen;
整行颜色
void __fastcall TFrm ::DBGridEh2DrawColumnCell(TObject *Sender, const TRect &Rect,
int DataCol, TColumnEh *Column, Gridseh::TGridDrawState State)
{
if (DBGridEh2->DataSource->DataSet->FieldByName("sex")->Value == "009")
{
DBGridEh2->Canvas->Brush->Color = clRed;
DBGridEh2->DefaultDrawColumnCell(Rect, DataCol, Column, State);
}
}