Visual Studio vs. #Develop - default event handlers

Visual Studio and SharpDevelop do not both set delegates to handle events in the same way. The way they are configured is slightly different. This makes it difficult to use VS in one place and #Dvelopment in another (in the same project).

For example, in VB Visual Studio does the following:

Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() End Sub 

AND...

 Friend WithEvents OK_Button As System.Windows.Forms.Button 

Thus, the control is declared not only with another area (this may also be a problem, but not the subject of this message), but with withevents. An event handler is then assigned to it by the position handles.

in #Develop, this is done like this:

 Sub OK_ButtonClick(sender As Object, e As EventArgs) End Sub 

and...

 Private button1 As System.Windows.Forms.Button 

Then in the InitializeComponent method

 AddHandler Me.button1.Click, AddressOf Me.OK_ButtonClick 

The most unpleasant thing about this, even if it is done in one way, another ideal will redo it, duplicate declarations and, of course, compile time errors.

Does anyone know of this, somehow configure default handlers? even if it’s just that they can be turned off, so can you just enter it manually?

+4
source share
4 answers

pull them out of .designer and link them manually in the constructor in the code behind .. designer is regenerated by the developer of any tool that you use

+4
source

Sharpdevelop is released under the LGPL, so you can always get the source code and make any changes.

For necessary changes, you may need to modify or override the InsertComponentEvent and CreateEventHandler methods in the VBNetDesignerGenerator class. It is in the FormsDesigner project.

You can get the source here .

+5
source

While I'm not the one who usually agrees with people who say that β€œthis project is open source, modify the code itself,” this is one of the cases where it may be a valid answer.

The reason #develop does things the way it does is because a direct port like C # adds event handlers, like

 AddHandler Me.button1.Click, AddressOf Me.OK_ButtonClick 

is simply a direct translation:

 this.button1.Click += new EventHandler(OK_ButtonClick); 

If you used C #, then both Visual Studio and #Develop handle event creation in code in exactly the same way.

Obviously, no one goes to the general Visual Basic USECASE in #Develop, and as I said above, this is one of those fringe cases where you just might have to tweak the code yourself, or maybe even contribute back to # Create a source for this particular case.

I'm sure everyone using #Develop for Visual Basic will appreciate this.

+4
source

This will not be the most practical suggestion, but I promise that it will work for you.

# Develop open source. So, theoretically, you could change the base code to the same behavior as Visual Studio .NET ... I'm not sure how involved it can be, but I thought I would share my thought ...

As an alternative to making changes yourself, you can contact the main team about this as a function request. Perhaps a donation will help ... Others may also be interested in this change.

Regards, Frank W.

0
source

All Articles