Click here to Skip to main content
15,886,860 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if(checkBox1==checked)**
            {
                textBox3.UseSystemPasswordChar=false;
                checkBox1.Text=Hide;
            }
            else if(checkBox1==unchecked) **           
            {    
                textBox3.UseSystemPasswordChar=true;
                checkBox1.Text=Show;
            }

**i am getting error syntax error '(' expected ....plz help
Posted

I would suggest buying a basic C# book and reading it, instead of guessing. For this code to work, you'd have to define controls called checked and unchecked, so that they could be compared. You should also consider posting the full error message to us, and perhaps reading it first.

C#
if (checkbox1.Checked)
{
}
else// no need to check, you already did
{
}



Also, don't use your email address as your user id, unless you like spam.
 
Share this answer
 
Comments
singlaNitish 30-Aug-10 1:57am    
but sir i actually want is when i check the text should be hide and when unchecked the text should be Hide dats y i have used else if
thankq
Christian Graus 30-Aug-10 2:02am    
Like I said, buy a book because you have NO idea what you're doing. If you check in the first line if the Checked property is true, then if that test did not pass, the Checked property MUST be false, that's why a second check is not needed. Oh, your code for the text on your checkbox is also utterly broken. To reiterate, you have no idea what you're doing, you are wildly guessing. You need to take a class or something.
singlaNitish 30-Aug-10 2:13am    
thanq sir
singlaNitish 30-Aug-10 2:19am    
please guide which book to follow
Christian Graus 30-Aug-10 2:48am    
Well, you marked someone else as the right answer, when I told you first, so, perhaps you should ask him. At this point in time, I don't think there's any books you CAN'T learn from, so just buy a basic book, like a learn C# in 24 hours or C# for dummies type book.
One more problem: checked is a key word, could not be use in other way. However, "@cheched" could be used.

Of course the whole idea is, wrong, deep misunderstanding of syntax, no idea of variables, etc. Hope by now OP has learned all that. ;-)

—SA
 
Share this answer
 
Hi,,

Try this

if (checkbox1.Checked)
{
  checkbox1.Text = ""; //Assign Blank to the checkbox text
}
else
{
  checkbox1.Text = "Some Text"; //Assign some text to checkbox
}


As Christian Graus said, try to be strong in basics

Regards,
Suresh
 
Share this answer
 
Comments
singlaNitish 30-Aug-10 2:13am    
thankq sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900