This question already has an answer here:
- How to access properties of a usercontrol in C# 5 answers
I've made a C#
user control with one textbox
.
How can I access the property of read only from outside the user control. thanks
This question already has an answer here:
I've made a C#
user control with one textbox
.
How can I access the property of read only from outside the user control. thanks
expose your textbox as a public property in the userControl and access it wherever you have used the usercontrol.
for example:
public class MyUserControl : UserControl
{
public TextBox MyTextBox
{
get
{
return txtBox1;
}
set
{
txtBox1 = value;
}
}
}
and to make it readonly do this:
myUserControl.MyTextBox.ReadOnly=true; //where myUserControl is instance of
//MyUserControl, you have used somewhere