Visual Studio 2012 adding _1 to click event handler - ide

Visual Studio 2012 is adding _1 to any click event handler I create in XAML
ie: I create a new WPF solution, drop a button, in XAML give button a Name, type 'click' and intellisense brings up 'New Event Handler', I click it, it creates event BUT its named btn_test_click_1
In VS2010 we don't get _1, how can I stop this happening its driving me mad?
UPDATE
I can confirm this has been fixed with VS2012 Update 2

I can confirm this has been fixed with VS2012 Update 2

It only does that when the IDE see that an existing event handler by the same name has been created. Make sure you delete the event handle info from the code file then go to the aspx file and remove any event handle connections on the control. Then save the file.

You can remove the _1 manually and as you say you only have one event handler, so there shouldn't be any other code logic that would run on your event.

Related

How to fix event handler not opening in code window after renaming my form?

I am running into an issue after I rename my existing form in Visual Studio 2022. After I rename my form and try to double click a button control in the design window to open it up in the code editor, it doesn't create the event handler.
I tried double clicking the control before renaming the form and it worked just fine. But after I renamed the form, it didn't. I renamed the form in the solutions explorer window, so I am not sure if that is the reason why it's happening?
I haven't had an issue like this before, so if anyone has an idea on why this is happening and how to fix it, it would be greatly appreciated!
You should try checking Form name property if it is correct try Re-build or restart solution.
If u rename then design form , make sure same name reflect in code page also also, if not then rename their also.
I figured out what was going on! I was using WinForms App instead of the Windows Form App (.NET Framework). Switching to the other application let me rename my form with ease.

VS 2019 Visual Basic navigation bar class list not refreshing when selecting

I recently installed VS 2019 Preview, and i'm facing this issue:
In my VB code editor, in the navigation bar, when i try to choose a class (button, dropdowlist,...) it's not working: the list of classes it's not refreshing, the class i tried to select is not selected, so i can't be able to edit/create an event for the class i need to edit. I manually have to search for the event, or to create it manually.
Is it malfunction of the Editor? is it a bad configuration? or do i need to re-install VS 2019 ...?
Thanks in advance, looking forward for your comments on above.
I am not sure why your chose the Preview edition. I never used it. I have the latest VS 2019. In my version I can choose any control on the form in the middle drop down and the events for that control appear in the right drop down.
Another way to add the stub for an event procedure. Is available in Design View. Select a control and view the properties window. On the toolbar choose the lightning bolt. All the events for that control are listed. Double click on the event you want and the stub will be inserted in the code editor.
Of course, you can always just type in the event procedure, as long as it has the correct signature and handles clause, it will work.

VB.net: Remove ToolStripPanel/ToolStripContentPanel

While working on a project VB.net project in Visual Studio 2013 Community, i accidently inserted the ToolStripPanel/ToolStripContentPanel controls combination.
Unfortunately however, I now cannot delete it. Can anyone advise as to how to go about doing this? There must surely be a way. Unfortunately, I cant just hit Undo either as the project has been saved since.
Copy the MenuStrip (Default name MenuStrip1) to another form in your project. Go back to the problem form. Right-click the ToolStripPanel, click Select, and then hit delete. This will delete everything. Copy MenuStrip1 back to the problem form, and your original menu should show up. You may have to add the 'Handles' clause back in to any menu events. For example, if you have an event procedure named 'MnuFileOpen_Click' you may have to reinsert 'Handles mnuFileOpen.Click.

VB.NET: How to change setting on Click events

Visual Studio with VB.net: If I create a copy of a button on the forms designer, the click event is added to the click event handler of the source button.
How do I change this behaviour ? I want the click event of the second button be wired to a totally new click handler code, not to the already existing one of the first button.
There are two ways to copy a button.
CTRL+C / CTRL+V (or same with right click menu). This will create a new button with a new event handler. Note that this new event handler is not created automatically, but will be created on button click in VS designer.
CTRL + drag a control into a new location. This will create a copy with the same event handler, i.e. add an event handler to already existing one. This is the behavior you are seeing.
I'd be interested to know the official reference about this behavior, found the above by experiment. I've used CTRL + drag copy method 95% of the time, and had the same question for quite a while. Fortunately, there is a quick fix for event wiring - read below.
If you used the wrong method, you can manually delete the wiring code (the second handles clause), then double-click the button in question to create new click event handler for it (not a big deal).

Deleting menu item results index error ("source not found")

In VB.Net 2010, whenever I delete a menu item on a Windows Form (a Mainmenu1 object), an exception is thrown at run-time suggesting that there is an index value missing -- essentially a "source not found" error. Do I need to go into the Mainmenu1 object on the bottom of the Form at design time and do something? (BTW, I have also tried deleting the source code for the menu item, and then the menu item, and the exception is still thrown).
Basically, something is occurring that is not allowing me to simply delete a menu item, and get a successful run thereafter.
I had this problem. The simple fix is to restore the menu by clicking undo. Then run the code to make sure it still works. When you have done this, CLOSE visual studio. Then open VS and load your project. Delete the item from the menu and run the project. Everything should be fine
I think you need to specify whether you were trying to delete the menu or menu item during run time, or during design time.
You said, an exception, indicating an index value was missing, thrown at run time. I think it might be depending on how you deleted the menu item. You didn't mention how you deleted the menu item.
Normally, when you choose a menu item from a menu at design time, and press the Delete key, it disappeared. And, the program still works fine.
And, another possibility, is that your form window designer and the background designer code is not properly synced.
You might know that, every .NET form objects, have their background designer code, which serves as a schema for everything on the form.
When you add a button onto the form, the Visual Studio add a line of code in the designer code file (normally if your form name is form1, the designer code file is form1.designer.vb or cs or whatever). When you change the background colour of the button, designer code file add a line of code to set the button's background colour.
So, you see, in your case, when you delete the menu item, your designer code file probably didn't successfully remove the code relating to that menu item. So, it throws an exception at run time.
Maybe, it's because of your Visual Studio installation.
So, my suggestion is, you should try debugging the project, line by line, by running the project with F6 or F11 (sorry, I don't remember the exact key, but you can find it in the Debug menu).
I hope I made a good sense for your problem!