怎么改变dbgrid指定行和列的某个单元格的颜色
解决方案 »
- 怎么用adotable控件写查询语句啊
- TStringStream与Edit.Text相互赋值的一个问题
- SQLMAIL
- 小弟硬盘里有许多 mht 文件,最近想些个程序从这些 mht 文件里提取纯文本,应该如何下手??3Q!!
- 请求各位帮忙(关于WinSocket)
- 那位高手帮个忙。急。
- ole对象与wordapplication可以一起使用吗?可以的话应该如何使用?
- **************只要能解决问题,多少分您开口***************
- 调用dll里模式窗体的问题,高手帮忙
- 谁能告诉我如何用Windows Internet共享实现家庭电脑共享Internet?
- 关于注册表:有没有方法一次性获取某个键及其子键名称?要求速度越快越好。
- 大虾帮忙运行下这段代码!!!盼您赐教!!!
DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
const TRect &Rect, TField *Field, TGridDrawState State)
{
AnsiString theState = dbgChkList->DataSource->DataSet->FieldByName("STATE")->AsString;
if (theState == "0")
for (int i = 0 ; i < dbgChkList->Columns->Count ; i++ )
dbgChkList->Columns->Items[i]->Color = clBlue;
else if (theState == "1")
for (int i = 0 ; i < dbgChkList->Columns->Count ; i++ )
dbgChkList->Columns->Items[i]->Font->Color = clPurple;
else if (theState == "2")
for (int i = 0 ; i < dbgChkList->Columns->Count ; i++ )
dbgChkList->Columns->Items[i]->Font->Color = clRed;
else if (theState == "9")
for (int i = 0 ; i < dbgChkList->Columns->Count ; i++ )
dbgChkList->Columns->Items[i]->Font->Color = clOlive;
DBGrid1->Canvas->Brush->Color = clLime;
dbgChkList->DefaultDrawDataCell(Rect, Field, State);
}这是CB源码,我从程序中拷出来,你可以修改一下。
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if column.Index = 0 then
begin
with dbgrid1.Canvas do
begin
column.Color := clred;
end;
end;
end;
dbgrid.cell[1,2].color=red
或
dbgrid.colmuns[i].row[k].color=red
大侠们谁能实现这样的函数,我给100分啊