Is there a way to set the Name property from the designer in C#VisualStudio 2019?

Asked 2 years ago, Updated 2 years ago, 71 views

Thank you for your help.

When creating Windows applications in VisualStudio 2019,
the controls you place on the form **Is there any way to set the **Name property from above the designer?

If you set it on the code side, you can do it with "xxx.Name="Ayeo"; but on the designer, this property is
It is not displayed.I don't need to change the code dynamically, and I want to do it in design.
I'd like to complete it with a designer, but could you tell me how to do it?

If it's a self-made property, it's displayed on the designer, but you can see the existing property
I couldn't find anything to do.

Enter a description of the image here

Thank you for your cooperation.

c# visual-studio

2022-09-30 21:44

1 Answers

Review and add
The name property change is not easy to use because it will be reset if you use the designer tool even a little as I wrote below.I think it's a bad idea to stick to this.

Instead, there is no problem if you change it in the Designer Tools/Properties window, and Tag is the one that holds the information and can be used to identify objects.

As you can see in the screenshot of the question, when you move the cursor to that field, it says "User-defined data associated with the object."

If you enter the data here, it will be reflected in the source and will not reset when you use other forms or controls in the designer tool.

If you are already using Tag for something, it is not good to add and duplicate applications, but if not, it is worth considering.
TagProperty

Here's the sauce.
TagSource

The following is the original answer:

I think I can rewrite the name as it is (it is a cool name on the property window), but is that not acceptable?
PropertyWindow

Example changed:
NewNamed

These things are just changing both the display on the screen and the Xxxx.Designer.cs source, so I think it's the same regardless of which one you mess with.The above results are from the following sources:
If you change the (Name), the control name (in this case, the CustomizeNamedButton1.Xxx part of CustomizeNamedButton1) has also changed.
Designer.cs Excerpt

There are some cautionary comments, but even if you edit the Xxxx.Designer.cs source directly on VisualStudio after setting it up, it will be reflected without any problems if the control name is changed.

In addition, if you want to change only the .Name property above without changing the control name here, you will not be able to do so on the property window.
Xxxx.Designer.cs Wouldn't it be the fastest way to view the source and change it directly?
There is no error when I change it to build as below.
FatherChanged

If you change something in the designer tool, not just the above controls, the .Name property changes to the same name as the controls, and if you want to change it separately, you must edit the source directly again.
It's very annoying.

If you want to separate the control object name from the .Name property, you will either not use any designer tools once you have changed it, or you will give up and rewrite it in the program.


2022-09-30 21:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.