Last post 2008???!!! So, I guess I won't expect much in 2014...

In VB, I would change the name of controls often. I'd start with textBox1 and later change it to txtInput or whatever. C# doesn't like this. When I do this, I get errors that the control with the old name is missing.

  1. To not go through this, I can get used to naming the control right away, but I'd rather...

  2. Change the name on the fly without the errors. Do I do a global search and replace or a rename or what? What is the easiest way to do this?

Recommended Answers

All 3 Replies

Change the name using the properties for the control. Right-click the control, and select "Properties". Look for "(Name)". Change the name there.

I do this with ReSharper. Advantage is that comments are also scanned.

If you are using Visual Studio, and in the Designer, you can simply change the Name in the controls properties. Doing so will update all the fields that are causing errors.

(however, if you can't, then you simply need to edit the values related to it within the designer file (the code part), and then anywhere else used).

The first way is very easy (only thing that sucks is events won't get renamed if a they contain a match to the old name)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.