Force Windows-Generated Code To Refactor?

Not Answered This post has 0 verified answers | 9 Replies | 2 Followers Thread's RSS feed.

rehemann
Points 3,908
Replied On: Mon, Aug 7 2017 12:52 PM Reply

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.

  • Post Points: 20

All Replies

Mike Bowshewicz
Points 11,205
Infragistics Employee
Replied On: Tue, Aug 8 2017 9:45 AM Reply

Hello,

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.

Sincerely,

Mike B
Software Developer

  • Post Points: 20
rehemann
Points 3,908
Replied On: Tue, Aug 8 2017 2:24 PM Reply

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.


  • Post Points: 20
Mike Bowshewicz
Points 11,205
Infragistics Employee
Replied On: Wed, Aug 9 2017 1:40 PM Reply

Hello,

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.

Sincerely,

Mike B
Software Developer

  • Post Points: 20
rehemann
Points 3,908
Replied On: Wed, Aug 9 2017 1:48 PM Reply

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.

  • Post Points: 20
Mike Bowshewicz
Points 11,205
Infragistics Employee
Replied On: Thu, Aug 10 2017 12:25 PM Reply

Hi Richard,

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.

Sincerely,

Mike B
Software Developer

  • Post Points: 20
rehemann
Points 3,908
Replied On: Thu, Aug 10 2017 12:50 PM Reply

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.  

  • Post Points: 20
Mike Bowshewicz
Points 11,205
Infragistics Employee
Replied On: Fri, Aug 11 2017 9:52 AM Reply

Hello,

As far as I know, there's no way to force this to happen automatically. Two things that might work:

  1. Manually rename the tools by editing the designer.cs file, or
  2. In design view, remove the tool from the UltraToolbarsManager, then recreate it.

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.

Sincerely,

Mike B
Software Developer

  • Post Points: 20
rehemann
Points 3,908
Replied On: Fri, Aug 11 2017 10:01 AM Reply

Never mind

  • Post Points: 20
Mike Bowshewicz
Points 11,205
Infragistics Employee
Replied On: Mon, Aug 14 2017 8:58 AM Reply

Hello,

Is there anything further I can do to assist you with this issue?

Sincerely,

Mike B
Software Developer

  • Post Points: 5
Page 1 of 1 (10 items) | RSS