Jump to content

What am i doing wrong???????

- - - - -

  • Please log in to reply
4 replies to this topic

#1
jbnonn

jbnonn

    Newbie

  • Members
  • PipPip
  • 15 posts
I'm trying to get this if statement to work. All the other ones work fine except this if statement, which has two jobs. Can some one please help or direct me in the right direction. Should I use a different method or what. Thanks

Sample Code

private void cbSearch_CheckedChanged(object sender, EventArgs e)
{
if (cbSearch.Checked == true)
MainForm.hdSearchdd.Visible = false;
MainForm.hdSearchtxt.Visible = false;
else
MainForm.hdSearchdd.Visible = true;
MainForm.hdSearchtxt.Visible = true;

#2
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
Try adding braces to your code:

private void cbSearch_CheckedChanged(object sender, EventArgs e)
        {
            if (cbSearch.Checked == true)
            {
                MainForm.hdSearchdd.Visible = false;
                MainForm.hdSearchtxt.Visible = false;
            }
            else 
            {
                MainForm.hdSearchdd.Visible = true; 
                MainForm.hdSearchtxt.Visible = true;
            }
        }
Also please encase your code like this: [CODE*]code here[/CODE*] just remove the '*' symbol.

~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#3
jbnonn

jbnonn

    Newbie

  • Members
  • PipPip
  • 15 posts
Thank you for you help, been working on this all day.

#4
sfhdweb

sfhdweb

    Newbie

  • Members
  • Pip
  • 2 posts

CommittedC0der said:

Try adding braces to your code:

private void cbSearch_CheckedChanged(object sender, EventArgs e)

        {

            if (cbSearch.Checked == true)

            {

                MainForm.hdSearchdd.Visible = false;

                MainForm.hdSearchtxt.Visible = false;

            }

            else 

            {

                MainForm.hdSearchdd.Visible = true; 

                MainForm.hdSearchtxt.Visible = true;

            }

        }
Also please encase your code like this: [CODE*]code here[/CODE*] just remove the '*' symbol.

~ Committed.

thanks for sharing this great info

#5
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
also, in terms of elegant code.. this is redundant

if (cbSearch.Checked == true) {

instead, just do this
if (cbSearch.Checked) {





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users