C# overrides for controls

  • Thread starter Thread starter ECVerify.com
  • Start date Start date
E

ECVerify.com

I posted this earlier but never got a response...so I am trying again

****************************

Hey everyone,

I have a simple (I hope question)

To get the events in C# I can go to the designer view and I can select
an event for any control or form via the lightning bolt...cool

To get an override for a form I can go to the class view and I can
drill down and get the overrides by right button over the method and
selecting the override and add from the context menu...ok, cool

*****But if I have a button on the form and I want the override of the
button there seems to be no way to get to it. I can see MyButton
listed but to get to the overrides seems impossible.

What I end up having to do is manually adding the override for controls only.

Please help me find how to add them another way.

Thanks, Ed,
 
Hi,

You can create overrides on the form because you are actually modifying a
class that is derived from Form.
However that is not true for your button as you are modifying an instance of
button.
You might consider deriving a yourbutton from Button and there do the
overrides.
 
Miha Markic said:
Hi,

You can create overrides on the form because you are actually modifying a
class that is derived from Form.
However that is not true for your button as you are modifying an instance of
button.
You might consider deriving a yourbutton from Button and there do the
overrides.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

ECVerify.com said:
I posted this earlier but never got a response...so I am trying again

****************************

Hey everyone,

I have a simple (I hope question)

To get the events in C# I can go to the designer view and I can select
an event for any control or form via the lightning bolt...cool

To get an override for a form I can go to the class view and I can
drill down and get the overrides by right button over the method and
selecting the override and add from the context menu...ok, cool

*****But if I have a button on the form and I want the override of the
button there seems to be no way to get to it. I can see MyButton
listed but to get to the overrides seems impossible.

What I end up having to do is manually adding the override for controls only.

Please help me find how to add them another way.

Thanks, Ed,

Thanks Miha,

Well it just seemes silly you can get to all the control overrides in
VB.NET and add them with the select of 2 dropdowns but it is difficult
to get add them in C#...thanks for the input, I think I will just
stick to manually creating them rather than deriving every control
that I want to use an override on...it will improve my typing skills
:)

Thanks again Miha for your suggestion.

Ed,
 
Hi Ed,

I think you're confusing overrides and events. When you're working in a form
you would, for example, override the OnLoad method to do your own processing
when the form loads. But, if you had a Button1 you would need to attach an
event handler to handle the Click event since, as Miha said, you cannot
override the OnClick method. Basically, overrides are for descendant classes
and events are for external classes. This is the same in Visual Basic.

What you are talking about is the ability to have the Visual Studio IDE
automatically add the event handler for you. In the C# case, select the
object's properties and click on the lightening bolt button. This will give
you the events for that object, you can then double click on the entry for
any particular event and the IDE will create the handler for you.


<snip>
 
Back
Top