Hi Brandon,
Based on my understanding, you have a CheckBox and two TextBoxes on a form.
If the CheckBox is not selected, you'd like to make the two TextBoxes
readonly; otherwise, make the two TextBox editable. If I'm off base, please
feel free to let me know.
Peter has given a good explanation about the conception of Enabled and
ReadOnly. If a TextBox is enabled, i.e. its Enabled property is set to true
and its ReadOnly property is set to true, we can not only type text in the
TextBox, but also select, copy and paste text in it; otherwise, we can do
neither of the above operations.
If a TextBox is enabled, and its ReadOnly property is set to false, we can
only select and copy the text in it.
From your description, you need to set the ReadOnly property of the two
TextBoxes to true to make them readonly.
The following is a sample. It requires that you add a CheckBox and two
TextBoxes on a form.
public partial class Form1 : Form
{
public Form1()
{
this.InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.ReadOnly = (this.checkBox1.CheckState !=
CheckState.Checked);
this.textBox2.ReadOnly = (this.checkBox1.CheckState !=
CheckState.Checked);
this.checkBox1.CheckStateChanged += new
EventHandler(checkBox1_CheckStateChanged);
}
void checkBox1_CheckStateChanged(object sender, EventArgs e)
{
this.textBox1.ReadOnly = (this.checkBox1.CheckState !=
CheckState.Checked);
this.textBox2.ReadOnly = (this.checkBox1.CheckState !=
CheckState.Checked);
}
}
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.