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.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file

MSSQL GROUP_CONCAT