event name in sharpdevelop - c#

i want to ask abt Sharpdevelop.
Can i change the control's event name in sharpdevelop ? I want to add "_" like in visual studio.
For Example, button click event in Sharp develop defaulted to Button1Click. can i change to Button1_Click like in visualstudio ?
Thanks.

Mike Webb's answer is the only way to generate an event handler method name with an underscore without modifying SharpDevelop's source code.
Lex Li's answer is also correct. There is no option in SharpDevelop to enable automatic generation of event handler method names that use an underscore. The only way currently is to modify the source code. It is a fairly straightforward code change.
Download the source for SharpDevelop.
Extract the code.
Locate the EventBindingService class (src\AddIns\DisplayBindings\FormsDesigner\Project\Src\Services\EventBindingService.cs)
Locate the CreateUniqueMethodName method.
Modify the single line of code in this method to use an underscore in the string format:
return String.Format("{0}_{1}", Char.ToUpper(component.Site.Name[0]) + component.Site.Name.Substring(1), e.DisplayName);
Build SharpDevelop from source code by running src\DebugBuild.bat or src\ReleaseBuild.bat
Then when you use your customised version of SharpDevelop and double click a button in the forms designer, for example, you will get an event handler with a name like "Button1_Click".
At some point in the future SharpDevelop 4 will allow this with an option that can be selected in Tools - Options.

Yes. If you go into design and look in the properties window for the control you will see a few icons at the top. One of these should give you the list of events (in VS it is a lightning bolt). In the left hand column are the linkable events and in the right hand column are the functions that are called when the events are triggered.
Simply rename the left hand field and make sure you have the function named correctly in code as well. You can also type a name into the left hand field and then double click inside it to generate the function automatically.

The underscore is evil to some people, like me :)
Well, if you do want the underscore, check out SharpDevelop source code and locate that part and modify it. It is open source, so you can do whatever you like to please yourself. I did not see a setting available somewhere, so modify the source code seems to be the only way to achieve your goal.

I know this is an old thread but in SharpDevelop v4.3 (v4.x - v5.x) there is a solution to this. In the past i've had to use the above method, however this one is much faster and easier.
Launch SharpDevelop and check the following setting:
Tools > Options > Windows Forms Designer > General > "Generate Visual Studio Style Event Handlers"

Related

Is it possible to enable/disable all breakpoints with project scope only (Visual Studio 2015 and above)?

Let's say I have a solution with 10 projects, it is an old code base and I am just getting familiar with it. I am doing a lot of debugging and putting breakpoints here and there. I would like to enable or disable all breakpoint in a given project (i.e data access project) but not in all the solution. I want to do this without manually disabling each breakpoint.
Is there a way to do this? If so, which is it? Is there an extension or third party tool that could help me? (I am using resharper but did not find any way to do this)
In the breakpoint panel, in the toolbar you can click on Columns and check Function. It will add a column with the fully qualified location of the breakpoint (well, up to the function name). Click on the Function header to sort by Function and your breakpoints will be sorted and thus grouped together. You can then shift select the range you want to disable and uncheck one of them, they will all be disabled.
This assumes a somewhat sane naming convention though.

How to get VC# to rebuild auto-generated .cs files?

I imagine this question has been asked and answered, but I cannot find it.
I wanted to make a simple GUI to interface to a windows 7 command. I usually use Wx, but since this was to be a windows-only thing, I decided to see if I could whip it out real fast using Visual C# 2010 Express, which I had never used before.
Things started off just great. I created a form, put a few buttons and text boxes and such on it, and hit Debug. It came up and ran just like that. No muss, no fuss. So I then designed the form just the way I wanted it, renamed the controls from "Button1" and so forth to meaningful names. But now it's a mess. By clicking around, I discovered that VC# had auto-generated two files called Form1.cs and Form1.Designer.cs. The later contains the bindings between functions and the events generated from user-clicks etc., and the former contains no-op code for those functions, for me to complete.
Problem is, the names are all still the original "Button1" and so forth, not the new ones, and the new controls I added after running the first time do not appear at all.
I want it to regenerate all that stuff afresh from the finished form. How to?
You probably don't have an actual problem, unless you edited something within Form1.Designer.cs. Provided you left that file alone, things should just work.
Whenever you double-click on a button, or use the events interface to create event handlers, the handlers are created with the following pattern:
ObjectName_EventName()
So, for example:
Button1_Click()
If you later change the name of Button1, the event handler's name is not changed, too. But it is still attached to the proper event, again - assuming you did not edit anything in Form1.Designer.cs
If you look (but don't touch!) inside Form1.Designer.cs, you will probably find something similar to:
MyNewButtonName.Click += Button1_Click;
(I don't recall the exact syntax the editor uses for wiring up event handlers; the principle is you should see your new button name being attached to the old handler name)

VS2010 highlight references only on doubleclick

Is it possible to make C# code editor in VS2010 only highlight word references when a word is doubleclicked, like e.g. MetalScroll, not always whenever the cursor is on a word?
Maybe there are some extensions that could do it? Is it even possible to affect this area of VS with an extension?
http://blogs.msdn.com/b/zainnab/archive/2010/04/14/the-best-of-visual-studio-2010-how-to-use-reference-highlighting.aspx
You could maybe use the information here to write a macro to enable/disable highlighting on demand (though it won't work on a double click)

Visual studio 2010 showing available events from code behind

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.

Available class events C#

in c# how can I get the available events of a class in order to begin programming code inside of it. I know that in form or usercontrol you can select the control and click the events button and click on the selected event to begin coding, but I mean a derived class which I want to code its methods or events.
Thanks!
The simplest way is to look in the documentation, to be honest.
If you're within the designer, your approach of using the properties window will work for other controls (buttons, textboxes etc) as well... and if you're in the IDE, you can type this. from any instance context (e.g. the constructor) and get a list of members up, including the events.
I would still suggest reading the documentation though - MSDN allows you to look at all members, or just the events (or methods, or whatever) at any one time. It's not terribly hard to peruse the list that way - and you can then check the details of the event so you can make sure you're using it properly, rather than just by guessing based on the name.
EDIT: As Aren mentions, there's also the Object Browser. Not my personal preference, but it's an option.
The events are listed in the IntelliSense popup window you'll get when you type the class reference variable name followed by a dot. They have a lightning bolt icon.
Many more organized ways to know what a class can do. You could read its documentation. Or browse its source code. Or use Reflector if there isn't any.
in Visual Studio 2010, they have got this new Help Library Manager where you can check for MSDN updates and download any updates or go to online directly. (you can also install Vendor API docs quite easily as well)

Categories