this is vb.net code below
VB Code:
Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter MsgBox(sender.Name) End Sub
how to do in c#.net :confused: :confused:
Printable View
this is vb.net code below
VB Code:
Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter MsgBox(sender.Name) End Sub
how to do in c#.net :confused: :confused:
Code://At some point in the load of your form, or the InitializeComponent, or whatever
TextBox1.Enter += new System.EventHandler(TextBox1_Enter);
//Then your handler proc
private void TextBox1_Enter(Object sender, System.EventArgs e) {
//Code
}
vb.net: sender.name
c#: ((TextBox)(sender)).Name <---cast the sender
Building this statement gives that 'object' doesnot contain definition for 'Name'Quote:
Originally Posted by mar_zim
whereas in VB it works fine when i give
:eek2: :eek2:VB Code:
Msgbox (sender.Name)
Quote:
Originally Posted by cutamacious
Well !!! I guess u missed out the braces count. Just verify that the code should be
MessageBox.show ( ( (Textbox)(sender) ) . Name )