This is a migrated thread and some comments may be shown as answers.

Virtualization

3 Answers 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Cristi71000
Top achievements
Rank 1
Cristi71000 asked on 18 Jul 2007, 12:32 PM
Hi,

I noticed something using your Windows controls for the first time: it seems that for some overloads virtualization was not used. For example:

Control[] ctrl = tabItem2.ContentPanel.Controls.Find(rb.Tag.ToString(), true);
ctrl[0].Focus();


behaves differently from

Control[] ctrl = tabItem2.ContentPanel.Controls.Find(rb.Tag.ToString(), true);
Telerik.WinControls.UI.RadTextBox rtb = (Telerik.WinControls.UI.RadTextBox)ctrl[0];
rtb.Focus();

Based on OO theory and best practices, both should behave the same, but in this case they don't.
From the above example it's noticeable that this problem is generated by the fact that the overload function is not virtual, so the compiler doesn't know to call the correct version based on the object content, instead of using the type.
Was this left like this intentional (and if so why?) or it's just a mishap?

Thanks,
Cristian

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 19 Jul 2007, 01:00 PM
Hi Cristi71000,

Your analysis of the used OO patterns in RadTextBox is correct. The focus method we utilize is implemented intentionally this way, because the base Control.Focus() method is not virtual and we've overloaded it for our purposes. 

Let us know if you have other questions, or suggestions on how we can improve the focus method.

 
Greetings,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Cristi71000
Top achievements
Rank 1
answered on 19 Jul 2007, 01:40 PM
I just wonder why MS decided to make the Control.Focus method non virtual - it seems like a major mistake for a class that is meant as a base class for all Windows controls.
0
Vassil Petev
Telerik team
answered on 19 Jul 2007, 01:58 PM
Good question, Cristi71000, we are not sure why MS decided to do it this way. It may be a good idea to ask this in the www.windowsclient.net Forums. I think the Microsoft MVPs will be able to handle your question better than we would.


Sincerely,
Rob
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Cristi71000
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Cristi71000
Top achievements
Rank 1
Vassil Petev
Telerik team
Share this question
or