I know it's not recommended, but I often go into the windows-generated code to add new tools to my UltraToolbarsManager control. This works like a champ. However, I was wondering if there's a way to force VB to refactor the code after I've done this? My ButtonTool and Appearance variables really need to be renamed and refactoring everything would make this happen. Anybody know how this could be done? I've brought my form up in the designer, but that doesn't seem to force the code to refactor.
You can force the designer code to reserialize by making a change on the design surface, such as resizing the form or changing its title. To ensure that your manually-added code is preserved, I would recommend closing and reopening the design view before doing this.
As you mentioned, manually editing designer code is not recommended. If at all possible, I would add code to the form's CS file instead of directly to the designer-generated code.
Please let me know if there is anything further I can do to assist you.
Mike BSoftware Developer
I tried changing the size of the form, the text and I even added a new group to the toolbarsmanager, but the manual code did not refactor. See the attached screen cap to see what I am talking about.
I apologize, but I am not sure what you are showing with that screenshot. How were you able to determine that the code did not reserialize? If your changes were reflected on the design surface, it is unlikely that serialization failed.
You might be able to rename the Appearances and Tools manually, but it's also possible that your names will be overwritten when the designer serializes again. Please try manually changing the names if you have not done so yet.
Is there a reason that these identifiers need to have specific names? My general recommendation would be to refer to tools using a key instead, to ensure that code changes had as small an impact as possible.
The screenshot is the windows-generated code form my VB form. Wherever you see a large number for a button tool is where I manually added them without going through the designer. I'm hoping to force a refactor so all the numbers start over again with 1 and run sequentially. I don't want to keep these numbers. I want them to change.
As far as I know, there is no guarantee that the numbers used for these identifiers will start from 1, nor that they will run sequentially. It is unusual that you need specific identifiers for these objects, since they are generated programmatically and are only in scope in the InitializeComponent method. Normally, it is not intended for the developer to need to use these objects directly.
Can you elaborate on this requirement? Also, is it possible to use another method to identify the objects such as keys, indices, or GUIDs?
Please let me know.
I don't need them to be specific values. They are only specific values because I manually typed them. I want them to reset and start over from 1, so I don't have ButtonTool93335 anymore.
As far as I know, there's no way to force this to happen automatically. Two things that might work:
Is there a reason that you want the identifiers in the designer.cs to start from 1? I may be able to provide a better suggestion if I understood this requirement better.
Is there anything further I can do to assist you with this issue?