Coming from VB.NET I rarely use C# in Visual Studio so I know this might be a n00b question, but, in the Code Editor window when coding in VB you can just click the name of the method from the far-right drop-down and if it's a grayed-out item it'll auto-generate the member and take you to it; in C# however, when I do that, it just opens up that clicked item in the designer code window ...
Is there a way to replicate the same behavior of VB in the C# code window?
For reference, this is what I'm referring to:
Update in reference to one of my comments below:
I'm new to C# and delegates, however, from what I've gathered, they say if this event happened run this method. But in Visual Studio (community 2017), I can't figure out where/how I am meant to go about defining/attaching them.
I'd appreciate an answer as I'm trying to go about switching a program I've previously written in Python over to C#.
I've looked through documentation, I've looked over questions already asked here, and none of them seem to give me the information I'm after.
To add delegates (in this case they're typically called "event handlers") to UI controls in WinForms, you should:
Select the control in the visual designer
Look at the Properties windows
Click the lightning bolt to view the events.
Either double-click the blank space next to an event to auto-generate a handler, or single-click and select an existing handler from the dropdown.
I'm new in C#, and I'm trying to use a design I made in a form and put it inside the other one. In Java this is possible with Scene builder. You just press include and choose your FXML file. Is there any way to do that in Visual Studio??
You can do this.
The word is User Control. Drag and drop everything to your newly created User Control , then after you made it, you can choose it later from the Tool box in Visual Studio, and also can use Drag and drop your User Control like any other tool to existing forms.
You are probably looking for UserControl.
Is there any way to do that in Visual Studio??
Yes there is, you can use a UserControl if you are targeting Winform. Similar exists for WPF as well.
I'm new on developing vs extensions and I wanted to write a simple extension that can be called in Visual Studio IDE by a shortcut key and shows a form with some textboxes and an add button in it, after clicking the button the form closes and those texts on textboxes get inserted into the code.
it'll be very good if you can show me an example on how to this.
thanks in advance!
The feature you'd like to achieve is similar to this feature: Walkthrough: Implementing Code Snippets. You can refer to this link for how to show dialog from code editor and insert code into it. And then customize the code and UI according to your requirement.
In work and in home I have VS2010 installed. But in work I have this one cool feature. On the code behind file I have two drop downs. When I select some object in the left one lets say a testButton or Default2 (a page class), on the right one I get all available events for that object and when I select an event Visual Studio autogenerates it in my code-behind file. In my home VS I actually have does 2 drop downs but they work different. I have available objects on the right one but when I select for example the testButton it shows me the aspx page and points this button :/ Should I set sommething in the VS configuration or maybe in work I have some addon which I'm not aware of? Any ideas?
This is not a VB-exclusive feature.
What you're looking for is called a navigation bar. In Visual Studio options, open Text Editor → C# → General, and you'll see an option called Navigation Bar. Enable it and click OK.
However, I believe this bar works a bit differently in VB and in C#. In C#, it only lists the existing classes and their methods; in VB, it will list all your controls and their events even if those don't exist yet.
Ok I think I've found the answer. It seems that this feature is only available when the current file is in VB.Net. In my opinion this suks :/
You need to go the design view, in the Properties box, click on Events (lighting bolt) and double click on the events you want to code behind:
(source: byte.net)
#shin is correct, this is a VB.NET only feature; Microsoft only had feedback reports dating back to 2004 mentioning this feature, so I have opened a new bug request with Microsoft regarding this; and also added feedback to Visual Studios account on UserVoice...
https://connect.microsoft.com/VisualStudio/feedback/details/688175/vs2010-c-add-page-event-handlers-to-asp-net-using-codebehind-navigation-bar-the-same-way-as-in-vb-net
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2244558-allow-c-to-add-event-handlers-to-classes-using-co
I encourage everyone who this issue effects to go and vote up & confirm this issue with them.
I dislike that C# doesn't provide such a useful time-saving function.
Up to Visual Studio 2010, only Vb.net has this feature: on code-behind page, the code panel upper-left drop down shows a control's name, and the right drop down shows this control's available events. When clicking this event we can get the code-block for this event. This feature is not available in C#.
Without above feature, we can still get a control's available events for both C# and Vb.net: We must select the control on the aspx page and choose the design view at the lower left corner, then on the Properties panel click the Event button (the lighting sign), then available actions will be shown, double-click the name of the event you want, the event code will be generated in code-behind.
It is most certainly is a VB only feature and has been reported on numerous occassions to Microsoft.
It is possible to see all the available Events in C# & Asp.net too, but not inside code window as possible in VB. But you can see all Events of any selected Control in its Property Window. Open Properties, then Click Events.
This and the feature to generate event handlers without having to switch to Design view for C# is finally coming in Visual Studio 2012. It was about time.
Even the 2012 feature is not enough. You still have to guess for Page level events (Init, PreRender, etc) and also files that haven't already been filled out for you like Global.asax, which depending on the template you started with may or may not have all the event handlers already specified.
Agreed that Event Handlers is one of the things VB has for years and years and years handled way better than C#. I can't count the number of times I've had to remind a fellow C# developer that some events do, in fact, exist.