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.
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 21, 2010, 10:23 PM EDT
You mean to say put a border line for the label and text box ?
George Paroglou147 reputationPosted Sep 21, 2010, 10:36 PM EDT
new background color for both of them and at the same time. Like the file marking in windows
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 21, 2010, 10:43 PM EDT
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 Paroglou147 reputationPosted Sep 21, 2010, 10:50 PM EDT
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 21, 2010, 10:55 PM EDT
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 Paroglou147 reputationPosted Sep 21, 2010, 10:59 PM EDT
Any idea how this change can be done instantly at the same time even I click on label or textbox?
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 21, 2010, 11:05 PM EDT
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;
}
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts