331 |
|
{ TIBTreeView } |
332 |
|
|
333 |
|
procedure TIBTreeView.ActiveChanged(Sender: TObject); |
334 |
– |
var AtTopLevel: boolean; |
334 |
|
begin |
335 |
|
if (csDesigning in ComponentState) then Exit; |
336 |
|
IBControlLinkChanged; |
341 |
|
end |
342 |
|
else |
343 |
|
begin |
345 |
– |
AtTopLevel := Items.TopLvlCount = 0; |
344 |
|
AddNodes; |
345 |
|
if not FLocatingNode and (Selected = nil) and (Items.TopLvlCount > 0) then |
346 |
|
begin |
367 |
|
if (FExpandNode = nil) or (TIBTreeNode(FExpandNode).KeyValue <> DataSet.FieldByName(KeyField).AsVariant) then |
368 |
|
begin |
369 |
|
Node := Items.AddChild(FExpandNode,DataSet.FieldByName(TextField).AsString); |
372 |
– |
if ImageIndexField <> '' then |
373 |
– |
Node.ImageIndex := DataSet.FieldByName(ImageIndexField).AsInteger; |
374 |
– |
if SelectedIndexField <> '' then |
375 |
– |
Node.SelectedIndex := DataSet.FieldByName(SelectedIndexField).AsInteger; |
376 |
– |
TIBTreeNode(Node).FKeyValue := DataSet.FieldByName(KeyField).AsVariant; |
370 |
|
Node.HasChildren := (HasChildField = '') or (DataSet.FieldByName(HasChildField).AsInteger <> 0); |
371 |
|
Inc(ChildCount); |
372 |
|
end; |
611 |
|
|
612 |
|
procedure TIBTreeView.Added(Node: TTreeNode); |
613 |
|
begin |
614 |
< |
if assigned(DataSet) and DataSet.Active and not FNoAddNodeToDataset then |
614 |
> |
if assigned(DataSet) and DataSet.Active then |
615 |
|
begin |
616 |
< |
DataSet.Append; |
616 |
> |
if not FNoAddNodeToDataset then |
617 |
> |
begin |
618 |
> |
DataSet.Append; |
619 |
> |
if (Node.Text = '') and not DataSet.FieldByName(TextField).IsNull then |
620 |
> |
Node.Text := DataSet.FieldByName(TextField).AsString; |
621 |
> |
FModifiedNode := TIBTreeNode(Node); |
622 |
> |
FDataLink.UpdateRecord; |
623 |
> |
end; |
624 |
|
TIBTreeNode(Node).FKeyValue := DataSet.FieldByName(KeyField).AsVariant; |
625 |
< |
if (Node.Text = '') and not DataSet.FieldByName(TextField).IsNull then |
626 |
< |
Node.Text := DataSet.FieldByName(TextField).AsString; |
627 |
< |
FModifiedNode := TIBTreeNode(Node); |
628 |
< |
FDataLink.UpdateRecord |
625 |
> |
if ImageIndexField <> '' then |
626 |
> |
Node.ImageIndex := DataSet.FieldByName(ImageIndexField).AsInteger; |
627 |
> |
if SelectedIndexField <> '' then |
628 |
> |
Node.SelectedIndex := DataSet.FieldByName(SelectedIndexField).AsInteger; |
629 |
|
end; |
630 |
|
inherited Added(Node); |
631 |
|
end; |