为什么树节点的字体没有改变,在线等
procedure TChdaForm.TrVwCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
i:Integer;
Ds:TAdoDataSet;
begin
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=FCn;
for i:=0 to Node.Count-1 do
begin
Ds.CommandText:=' select isnull(f_color,0) as f_color,isnull(f_bold,0) as f_bold from '+TABLENAME+
' where '+BMFIELD+'='''+copy(Node.Item[i].Text,1,pos(' ',Node.Item[i].Text)-1)+''' and '+
' f_jb=(select isnull(f_jb,0)+1 from '+TABLENAME+' where '+BMFIELD+'='''+copy(Node.Text,1,pos(' ',Node.Text)-1)+''')';
Ds.open;
if Ds.Bof and Ds.Eof then Exit
else
begin
Ds.First;
with (Sender as TTreeview).Canvas.Font do
begin
Color:=Ds.FieldValues['f_color'];
case Ds.FieldValues['f_bold'] of
0: Style:=Style-[fsBold];
1: Style:=Style+[fsBold];
end;
end;
end;
Ds.Close;
end;
finally
Ds.Close;
Ds.Free;
end;
end;