我现在在程序中有30个DBGRID,在每个DBGIRD的OnDrawColumnCell中写下下面的代码
for j:=0 to ListBox3.Count-1 do
if(Column.FieldName=ListBox3.Items[j])then
bsSkinDBGrid1.Canvas.Brush.color:=clGradientActiveCaption;
bsSkinDBGrid1.DefaultDrawColumnCell (Rect,DataCol,Column,State);
但是我不想用手工进行写,我想通过程序在formshow中写一个事件来接管我
手工在OnDrawColumnCell中写代码。我的思路是写一个函数叫RefreshDBGridColumn里面
包含上面的代码,然后通过在发romshow中写类似如下代码
for i:=1 to 24 do
begin
TBsskindbgrid('bsskindbgrid'+inttostr(i)).OnDrawColumnCell:=RefreshDBGridColumn;
end;
这当然是我的思路,肯定不对,哪位DBGRID的高手中的高手能指点迷津,最好给出代码来!
谢谢!
for j:=0 to ListBox3.Count-1 do
if(Column.FieldName=ListBox3.Items[j])then
bsSkinDBGrid1.Canvas.Brush.color:=clGradientActiveCaption;
bsSkinDBGrid1.DefaultDrawColumnCell (Rect,DataCol,Column,State);
但是我不想用手工进行写,我想通过程序在formshow中写一个事件来接管我
手工在OnDrawColumnCell中写代码。我的思路是写一个函数叫RefreshDBGridColumn里面
包含上面的代码,然后通过在发romshow中写类似如下代码
for i:=1 to 24 do
begin
TBsskindbgrid('bsskindbgrid'+inttostr(i)).OnDrawColumnCell:=RefreshDBGridColumn;
end;
这当然是我的思路,肯定不对,哪位DBGRID的高手中的高手能指点迷津,最好给出代码来!
谢谢!
if Self.Components[i] is TDBGrid then
TDBGrid(Self.Components[i]).OnDrawColumnCell := RefreshDBGridColumn;
for i := 0 to Self.ComponentCount-1 do
if Self.Components[i] is TDBGrid then
if (Self.Components[i] as TDBGrid).tag=100 then
(Self.Components[i] as TDBGrid).OnDrawColumnCell := RefreshDBGridColumn;这样的好处是可以精确控制要操作的DBGrid,如第1到10个DBGrid的TAG设为100,其它的设为200,这样就能分别控制你想要控制的DBGrid了。
for i := 0 to Self.ComponentCount-1 do
if Self.Components[i] is TDBGrid then
begin
case (Self.Components[i] as TDBGrid).tag do
100: (Self.Components[i] as TDBGrid).OnDrawColumnCell := RefreshDBGridColumn;
200: (Self.Components[i] as TDBGrid).OnDrawColumnCell := nil;
........
end;
end
还有csdyyr(杨溢) 你给我的上面的代码中,我主要想知道
refreshDBGridColumn的函数怎么定义和内容怎么写呢?
for j:=0 to ListBox3.Count-1 do
if(Column.FieldName=ListBox3.Items[j])then
bsSkinDBGrid1.Canvas.Brush.color:=clGradientActiveCaption;
bsSkinDBGrid1.DefaultDrawColumnCell (Rect,DataCol,Column,State);
这些语句中有Rect,DataCol,Column,State参数,这些参数怎么定义!