I have a label and a textbox in the same line. I want be marked together after clicking on either the label or the textbox.
any ideas how this can be done?
Thanks in advanced
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manikavelu VelayuthamPosted Sep 22, 2010, 3:05 AM
Change the color of the label and textbox on click of the Label as well as Textbox as below
Below code will work
private void label2_Click(object sender, EventArgs e)
{
label2.BackColor = Color.Red;
textBox1.BackColor = Color.Red;
}
private void textBox1_Click(object sender, EventArgs e)
{
label2.BackColor = Color.Red;
textBox1.BackColor = Color.Red;
}
George ParoglouPosted Sep 22, 2010, 2:59 AM
Any idea how this change can be done instantly at the same time even I click on label or textbox?
Manikavelu VelayuthamPosted Sep 22, 2010, 2:55 AM
If its web application, you can go for Javascript. Its so simple to use javascript and avoids the unnecessary refresh of the page, i mean it avoids the postback.
If its windows application you can directly write the code in C#.
George ParoglouPosted Sep 22, 2010, 2:50 AM
Manikavelu VelayuthamPosted Sep 22, 2010, 2:43 AM
Just write a OnClick event in javascript for the Label as well as TextBox.
Change the background color of the
Change to default color in OnBlur event of the
George ParoglouPosted Sep 22, 2010, 2:36 AM
new background color for both of them and at the same time. Like the file marking in windows
Manikavelu VelayuthamPosted Sep 22, 2010, 2:23 AM
You mean to say put a border line for the label and text box ?