Recent

Author Topic: Form1.TreeView new items Form5.TreeView  (Read 275 times)

BIT

  • Jr. Member
  • **
  • Posts: 73
Form1.TreeView new items Form5.TreeView
« on: August 06, 2019, 07:28:44 am »
Hello as I can not learn how to work with TreeView.
I had this problem when creating Items when clicking on the Form5 button.Button2 occurs this code
( Form1.TreeView := Form5.TreeView) is not working correctly , what am I doing wrong?
I think the problem in this line is NewNode := Form1.TreeView1.Items.AddChild(Form5.TreeView1.Selected, Edit1.Text);
I'm doing an analog to create a file.

Code: Pascal  [Select]
  1.  
  2.  //Создать файл в   TreeView1
  3. procedure TForm5.Button2Click(Sender: TObject);
  4.   var
  5.     NewNode:TTreeNode;
  6. begin
  7.  
  8.   try
  9.  
  10.     if (Edit1.Text > '') and ( TreeView1.Selected.Parent <> nil ) then
  11.     begin
  12.  
  13.       NewNode :=  Form1.TreeView1.Items.AddChild(Form5.TreeView1.Selected, Edit1.Text);
  14.  
  15.         if (Form1.NewTab(ExtractFileName(Edit1.Text)) = True) then
  16.         begin
  17.           Form1.SynEditComandeTab('Hint', string(Form1.TreeView1.Selected.Data) +
  18.             '\' + Edit1.Text + '.uc');
  19.           Form1.SynEditComandeTab('SaveFile', '');
  20.           Form1.SynEditComandeTab('LoadFile', string(Form1.TreeView1.Selected.Data) +
  21.             '\' + Edit1.Text + '.uc');
  22.           NewNode.Data := nil;
  23.           string(unit1.u) := string(Form1.TreeView1.Selected.Data) + '\' + Edit1.Text + '.uc';
  24.           NewNode.Data := unit1.u;
  25.           NewNode.ImageIndex := 804;
  26.           NewNode.SelectedIndex := 785;
  27.           NewNode.MakeVisible;
  28.           Form1.TreeView1.Selected.Expand(True);
  29.           Form1.TreeView1.Selected := NewNode;
  30.         //  Form1.TreeView1.Items.Assign(TreeView1.Items);
  31.  
  32.           Close;
  33.         end;
  34.  
  35.  
  36.     end;
  37.   finally
  38.   end;
  39.  
  40.  
  41.  
  42. end;                            
  43.  
  44.  

« Last Edit: August 06, 2019, 07:43:22 am by BIT »

BIT

  • Jr. Member
  • **
  • Posts: 73
Re: Form1.TreeView new items Form5.TreeView
« Reply #1 on: August 06, 2019, 08:09:51 pm »
Made differently this code is not relevant.