I'm developing C# skills after years of working with VB.NET. I am having difficulty finding out what events are available with a control, and how to relate an event handler to the event that I want to use.
In VB I'd click a control on a form and the default event handler would be added. For example, click on a textbox and this is added
Of course exactly the same happens with C#
The C# code even looks a bit neater. But what if I want another event type? With VB.NET I could click anywhere in the event handler and Visual studio would show me a list of all the event handlers that are available for this control
I can click one of these to insert another event handler for the control, or (as you can see from the code fragment in the image) I could change the Handles clause to switch my original TextChanged code to a different event.
I'm having difficulty doing something similar with C#. If I click on the event handler for txtLastName_TextChanged, I see this, which does not give me the list of events relevant to txtLastName that I found so convenient in VB.NET.
Also, I find that if I delete the unwanted event handlers like txtPhoneo_TextChanged my form won't compile any more. If I add an event handler like txtLastName_Validated it is ignored, it is not automatically hooked up. Even when I do know the event names, I don't know how to hook it up.
So what don't I understand? I'm guessing that there are simple techniques, or options in Visual Studio that I haven't set up correctly, that will make C# as convenient as VB.NET.
Thank you, Robert Barnes.
In VB I'd click a control on a form and the default event handler would be added. For example, click on a textbox and this is added
VB.NET:
Private Sub txt1ry_TextChanged_1(sender As Object, e As EventArgs) Handles txt1ry.TextChanged
End Sub
C#:
private void txtLastName_TextChanged(object sender, EventArgs e)
{
}
I can click one of these to insert another event handler for the control, or (as you can see from the code fragment in the image) I could change the Handles clause to switch my original TextChanged code to a different event.
I'm having difficulty doing something similar with C#. If I click on the event handler for txtLastName_TextChanged, I see this, which does not give me the list of events relevant to txtLastName that I found so convenient in VB.NET.
Also, I find that if I delete the unwanted event handlers like txtPhoneo_TextChanged my form won't compile any more. If I add an event handler like txtLastName_Validated it is ignored, it is not automatically hooked up. Even when I do know the event names, I don't know how to hook it up.
So what don't I understand? I'm guessing that there are simple techniques, or options in Visual Studio that I haven't set up correctly, that will make C# as convenient as VB.NET.
Thank you, Robert Barnes.