View Single Post
  #1 (permalink)  
Old August 5th, 2015, 11:48 PM
kiatisak kiatisak is offline
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Code is changed when the form has changed--how to avoid?

I am writing a window form program, of course with C#.
I have tried to create control variable manually for the sake of my purpose.
But when I go to the form and make changes in the form, even just re-size the form, the name of control variables in the code were changed. I do not want this to happen. How can I configure/do to avoid this.

Thanks in advance.

To be more specific, I am working with TreeView control and I declare the variables responsible for nodes collection, trnXxx, and set up them as fragment of codes shown below.

this->tvwOutline->Dock = System::Windows::Forms::DockStyle::Left;
this->tvwOutline->ImageIndex = 0;
this->tvwOutline->ImageList = this->imgOutline;
this->tvwOutline->Location = System::Drawing::Point(0, 0);
this->tvwOutline->Name = L"tvwOutline";
this->trnPoints->ImageIndex = 6;
this->trnPoints->Name = L"trnPoints";
this->trnPoints->SelectedImageIndex = 7;
this->trnPoints->Text = L"Points";
this->trnLines->ImageIndex = 8;
this->trnLines->Name = L"trnLines";
this->trnLines->SelectedImageIndex = 9;
this->trnLines->Text = L"Lines";
this->trnSketch->Checked = true;
this->trnSketch->ImageIndex = 2;
this->trnSketch->Name = L"trnSketch";
this->trnSketch->SelectedImageIndex = 3;
this->trnSketch->Text = L"Sketch";
this->trnModel->ImageIndex = 4;
this->trnModel->Name = L"trnModel";
this->trnModel->SelectedImageIndex = 5;
this->trnModel->Text = L"Model";
this->trnOutline->Checked = true;
this->trnOutline->ImageIndex = 0;
this->trnOutline->Name = L"trnOutline";
this->trnOutline->SelectedImageIndex = 1;
this->trnOutline->Text = L"tree Outline";
this->tvwOutline->Nodes->AddRange(gcnew cli::array< System::Windows::Forms::TreeNode^ >(1) {trnOutline});
this->tvwOutline->SelectedImageIndex = 1;
this->tvwOutline->Size = System::Drawing::Size(227, 440);
this->tvwOutline->TabIndex = 0;
this->tvwOutline->ExpandAll();

Then I just adjust the size of the form, it changes my code like this

this->tvwOutline->Dock = System::Windows::Forms::DockStyle::Left;
this->tvwOutline->ImageIndex = 0;
this->tvwOutline->ImageList = this->imgOutline;
this->tvwOutline->Location = System::Drawing::Point(0, 0);
this->tvwOutline->Name = L"tvwOutline";
treeNode1->ImageIndex = 6;
treeNode1->Name = L"trnPoints";
treeNode1->SelectedImageIndex = 7;
treeNode1->Text = L"Points";
treeNode2->ImageIndex = 8;
treeNode2->Name = L"trnLines";
treeNode2->SelectedImageIndex = 9;
treeNode2->Text = L"Lines";
treeNode3->Checked = true;
treeNode3->ImageIndex = 2;
treeNode3->Name = L"trnSketch";
treeNode3->SelectedImageIndex = 3;
treeNode3->Text = L"Sketch";
treeNode4->ImageIndex = 4;
treeNode4->Name = L"trnModel";
treeNode4->SelectedImageIndex = 5;
treeNode4->Text = L"Model";
treeNode5->Checked = true;
treeNode5->ImageIndex = 0;
treeNode5->Name = L"trnOutline";
treeNode5->SelectedImageIndex = 1;
treeNode5->Text = L"tree Outline";
this->tvwOutline->Nodes->AddRange(gcnew cli::array< System::Windows::Forms::TreeNode^ >(1) {treeNode5});
this->tvwOutline->SelectedImageIndex = 1;
this->tvwOutline->Size = System::Drawing::Size(227, 440);
this->tvwOutline->TabIndex = 0;

The variables trnXxx are changed to treeNodeX with trnXxx still being declared. Can anyone give me suggestion on how to cope with this problem.

Last edited by kiatisak; August 6th, 2015 at 02:51 AM..
Reply With Quote