VB.NET and C# event

It is convenient to set up a handler for the controls in .NET, either C# or VB.NET, as compare to C++, Win32. Code snippet below.


VB.NET

Friend WithEvents oCombo As System.Windows.Forms.ComboBox
'expecting this control to have certain events to catch

Private Sub oCombo_OnMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles oCombo.OnMouseUp
'the Handles function tell what event to handle

MsgBox("hello")

End Sub


C#

Public System.Windows.Forms.ComboBox oCombo;
this.oCombo.OnMouseUp+= new Windows.Forms.MouseEventHandler(this.OnComboMouseUp);

private void
OnComboMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
MessageBox.Show("Hello");
}




Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Tips on how to use IBM iNotes (web client) on emailing or scheduling - Like copy tables from Excel or checking for user id (windows logon id) through email address