TNodeData1 =
class
public
Column0:
String;
Column1:
String;
Column2:
String;
Column3:
String;
Column4:
String;
Column5:
String;
Column6: TButton;
end;
procedure TFormb.DoResize(node: pvirtualnode);
var
CellRect: trect;
d: TNodeData1;
begin
d:=TNodeData1(VirtualStringTree1.GetNodeData(node)^);
CellRect := VirtualStringTree1.GetDisplayRect(node, 6, false);
with d.Column6
do
begin
Left := CellRect.Left;
Width := CellRect.Right-CellRect.Left;
Top := CellRect.Top;
Height := CellRect.Bottom-CellRect.Top;
end;
end;
Procedure TFormb.SPMEditQueryGrid(DBName, Statement:
String; Target:TVirtualStringTree; Titles: Boolean);
Var Col,i,j, Lin, nCol: Integer;
d: TNodeData1;
begin
With TQuery.Create(
Nil)
Do
Try
DatabaseName := DBName;
SQL.Text := Statement;
Open;
If Not IsEmpty
Then
Begin
//For Col := 0 To FieldCount - 1 Do
// Target.Header.Columns[col].Text := Fields[Col].FieldName;
While Not Eof
Do
Begin
d:=TNodeData1.Create;
d.Column1 := Fieldbyname('
id_employe').AsString;
d.Column2 := Fieldbyname('
Collaborateur').AsString;
d.Column3 := Fieldbyname('
INTITULE_SERVICE').AsString;
d.Column4 := formatfloat('
0.00',Fieldbyname('
NOMBRE_JOURS').Asfloat);
d.Column5 := formatfloat('
0.00',Fieldbyname('
Montant').Asfloat);
edtXnode := Target.AddChild(Target.FocusedNode,d);
d.Column6 := TButton.Create(self);
with d.Column6
do
begin
inc(incnamebutton);
name := '
tata'+inttostr(incnamebutton)+Fieldbyname('
id_employe').AsString;
Parent := VirtualStringTree1;
OnClick := ButtonClick;
Target.inValidateNode(edtXnode);
DoResize(edtXnode);
end;
Next;
End;
End;
Finally
Close;
Free;
End;
end;
{ QueryGrid }