如何覆盖c#.net中控件的内置方法 [英] how to overwrite the inbuild methods of the controls in c#.net
问题描述
大家好,
我正在使用c#.net Windows应用程序,并且在一项要求中,我需要更改内置c#.net控件的方法的参数,关于这一点,任何人都可以帮助我...
请参阅自定义工具提示下面的CodeLine-1,其方法名为"show",此处将仅使用控件作为显示工具提示的引用,我需要更改该方法,例如codeLine-2
CodeLine-1:CustomTooltip.Show(SomeText,control1);
codeLine-2:CustomTooltip.Show(SomeText,SomeText);
任何人都可以帮助我达到目标
我不希望与我需要的任何控件相关的工具提示与某些文本相关.
HI TO ALL,
i am working with c#.net windows application and in one of requrement i need to chage the parameters of a method of the inbuild c#.net control can any one pls help me regarding this...
see the CodeLine-1 below the custom tooltip have method called "show" here it will take only controls as the references to show the tooltip i need to change the method some thing like codeLine-2
CodeLine-1:CustomTooltip.Show(SomeText, control1);
codeLine-2:CustomTooltip.Show(SomeText, SomeText);
any one pls help me how achive it
I dont want the tooltip associated with any control i need it is associated with some text
推荐答案
您的问题不是很清楚.
如果我对您的理解正确,则可以从内置类继承您自己的类,然后使用例如new
关键字覆盖方法.
但是,您不能使用此技术用不同于原始参数的其他一些参数替换方法,您可以替换"原始实现.有关更多信息,请参见: http://msdn.microsoft.com/zh-cn/library/51y09td4(v = vs.71).aspx#vclrfnew_newmodifier [扩展方法 [
Your question isn''t very clear.
If I understood you correctly, you can inherit your own class from the built in class and then use for examplenew
keyword to override a method.
However, you cannot use this technique to replace a method with some other parameters that are different than original parameters, you can just ''replace'' the original implementation. For more info see: http://msdn.microsoft.com/en-us/library/51y09td4(v=vs.71).aspx#vclrfnew_newmodifier[^].
You can add new methods for inherited classes that are not included in the original class and you can also use extension methods[^] to add functionality to a builtin class without having to derive a new class from it if that''s what you''re after.
希望此链接可能对您有帮助
http://www.csharp-station.com/Tutorials/lesson19.aspx [ ^ ]
hope this link may help u
http://www.csharp-station.com/Tutorials/lesson19.aspx[^]
这篇关于如何覆盖c#.net中控件的内置方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!