I have inherited DateTimePicker control in a custom UserControl but now the usercontrol does not have some properties like Value, Format, etc. How do I override / access these properties in my main form when I use these usercontrols?
4 Answers, 1 is accepted
0
Hello Priyam,
Thank you for writing.
I am not quite sure what do you mean by "I have inherited DateTimePicker control in a custom UserControl". Perhaps, you have added RadDateTimePicker to a UserControl, if so and you cannot access the RadDateTimePicker from a Form hosting the UserControl, then you just need to add a property to the UserControl, which returns the RadDateTimePicker control, or just change its Modifier to Public.
If this is not the case, please provide more details about the precise scenario and I will gladly assist you with it.
Regards,
Stefan
Telerik
Thank you for writing.
I am not quite sure what do you mean by "I have inherited DateTimePicker control in a custom UserControl". Perhaps, you have added RadDateTimePicker to a UserControl, if so and you cannot access the RadDateTimePicker from a Form hosting the UserControl, then you just need to add a property to the UserControl, which returns the RadDateTimePicker control, or just change its Modifier to Public.
If this is not the case, please provide more details about the precise scenario and I will gladly assist you with it.
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Ke
Top achievements
Rank 1
answered on 09 Mar 2016, 02:21 AM
Hi Stefan,
I have came across the same problem. How do I add a property to the UserControl, so that it returns the base radcontrol property? Can you show me one example, please? thank you!
0
Hello ,
Thank you for writing.
If I understand your scenario correctly, you have a UserControl that contains a specific RadControl. Then, the UserControl is added to the Form and you need to access the RadControl's properties from the Form. In order to achieve it, you can follow the explained approach in Stefan's post: "you just need to add a property to the UserControl, which returns the RadDateTimePicker control". Thus, you will be able to access the RadDateTimePicker from the Form. Here is demonstrated a sample code snippet:
If it is not suitable to your case, it would be greatly appreciated if you can provide more details about the precise case and the exact goal that you are trying to achieve. Thus, we would be able to think about a suitable solution and assist you further. Thank you.
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik
Thank you for writing.
If I understand your scenario correctly, you have a UserControl that contains a specific RadControl. Then, the UserControl is added to the Form and you need to access the RadControl's properties from the Form. In order to achieve it, you can follow the explained approach in Stefan's post: "you just need to add a property to the UserControl, which returns the RadDateTimePicker control". Thus, you will be able to access the RadDateTimePicker from the Form. Here is demonstrated a sample code snippet:
public
partial
class
UserControl1 : UserControl
{
public
UserControl1()
{
InitializeComponent();
}
public
RadDateTimePicker DateTimePicker
{
get
{
return
this
.radDateTimePicker1;
}
}
}
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
this
.userControl11.DateTimePicker.Value =
new
DateTime(2016, 1, 1);
}
}
If it is not suitable to your case, it would be greatly appreciated if you can provide more details about the precise case and the exact goal that you are trying to achieve. Thus, we would be able to think about a suitable solution and assist you further. Thank you.
I hope this information helps. Should you have further questions I would be glad to help.
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Ke
Top achievements
Rank 1
answered on 10 Mar 2016, 05:11 PM
Thank you for your examples. They are great to understand.
I did exactly the same thing to change the backcolor of dropdownlist. And last night I realized that both my ways of changing accessibility to visual elements are correct. Thank you again for your examples to confirm.