怎么把tdbgrid在代码里改字体
比方说第2行的字体改一下..在代码里怎么实现
[解决办法]
在DBGrid的OnDrawDataCell事件中添加以下代码:
void __fastcall TForm1::DBGrid1DrawDataCell(TObject *Sender,
const TRect &Rect, TField *Field, TGridDrawState State)
{
TDBGrid *dbg = (TDBGrid *)Sender;
if(dbg-> DataSource-> DataSet-> RecNo == 2) // 第二行
{
dbg-> Canvas-> Font-> Name = "verdana ";
dbg-> Canvas-> Font-> Size = 8;
dbg-> Canvas-> Font-> Color = clBlue;
dbg-> Canvas-> FillRect(Rect);
dbg-> Canvas-> TextRect(Rect, Rect.Left+2, Rect.Top+2, Field-> AsString);
}
}