Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2012/5.0 > C# 2012/5.0 General Discussion
|
C# 2012/5.0 General Discussion Discussions about the C# 2012 language and tool not related to any specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2012/5.0 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2015, 11:48 PM
Registered User
 
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..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Value Changed oleinik BOOK: Microsoft SQL Server 2008 Integration Services Problem-Design-Solution 0 April 12th, 2010 06:32 PM
Problem when a code changed with call template rakesh XSLT 5 July 24th, 2008 11:16 AM
How can the mousepointer be changed? apike VBScript 0 April 17th, 2007 10:38 PM
Same file or changed? jacob C# 2 July 8th, 2005 09:09 PM
Getting CHANGED value from Datagrid? Ron Howerton Pro VB.NET 2002/2003 5 January 5th, 2005 02:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.