Post: Please i need Help me C#
08-22-2013, 09:55 AM #1
MoTmrD
Banned
(adsbygoogle = window.adsbygoogle || []).push({}); hey NextGenUpdate


Please i need help C# Checked on God mode Checked Off God mode Off
(adsbygoogle = window.adsbygoogle || []).push({});
08-22-2013, 03:11 PM #11
Sonoro
I like anteaters
Originally posted by MoTmrD View Post
Process does not work


You can still use this other way. (Still under the checkedchanged event)

    if(MyCheckBox.CheckState == CheckState.Checked)
{
// Your code when it gets checked
}
else if(MyCheckBox.CheckState == CheckState.Unchecked)
{
// Your code when it gets unchecked
}
08-22-2013, 03:36 PM #12
MoTmrD
Banned
Originally posted by xSonoro View Post
You can still use this other way. (Still under the checkedchanged event)

    if(MyCheckBox.CheckState == CheckState.Checked)
{
// Your code when it gets checked
}
else if(MyCheckBox.CheckState == CheckState.Unchecked)
{
// Your code when it gets unchecked
}


thx you god work
08-23-2013, 04:38 AM #13
Pichu
RIP PICHU.
Originally posted by MoTmrD View Post
thx you god work


Here is an alternative that I prefer:

    
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked.Equals(true))
{
MessageBox.Show("Hello, Checkbox is checked");
}
else
{
MessageBox.Show("Hello, Checkbox is not checked");
}
}


The difference here is that it determines the bool immediately. CheckState.Checked has to determine the state of the checkbox, return a bool value, then Check and Compare the values.

Mine simply checks the state, returns a bool and then compares to see if it is or isn't.
03-04-2014, 03:41 AM #14
i use the code u said & when i check the 2nd time (tunring it off) nothing happens
03-04-2014, 03:00 PM #15
Default Avatar
Oneup
Guest
Originally posted by Pichu View Post
Here is an alternative that I prefer:

    
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked.Equals(true))
{
MessageBox.Show("Hello, Checkbox is checked");
}
else
{
MessageBox.Show("Hello, Checkbox is not checked");
}
}


The difference here is that it determines the bool immediately. CheckState.Checked has to determine the state of the checkbox, return a bool value, then Check and Compare the values.

Mine simply checks the state, returns a bool and then compares to see if it is or isn't.

Must say I have never seen anyone ever do

    (checkBox1.Checked.Equals(true))


Shouldn't it be
    (checkBox1.Checked == true) 
03-05-2014, 02:12 AM #16
Pichu
RIP PICHU.
Originally posted by 1UP View Post
Must say I have never seen anyone ever do

    (checkBox1.Checked.Equals(true))


Shouldn't it be
    (checkBox1.Checked == true) 


== is a reference to an object. .Equals is a virtual method that checks for value of an object. It compares a value.

In this case, either can be used.
03-05-2014, 08:40 AM #17
Default Avatar
Oneup
Guest
Originally posted by Pichu View Post
== is a reference to an object. .Equals is a virtual method that checks for value of an object. It compares a value.

In this case, either can be used.


Well I know that, I just never ever see anyone do it that way. Just seems wrong.
03-06-2014, 08:59 AM #18
Pichu
RIP PICHU.
Originally posted by 1UP View Post
Well I know that, I just never ever see anyone do it that way. Just seems wrong.


Never ran into any problems doing it that way and I've seen some others do it.

I know in Java there is a difference that would crash the compiler but in C#, it just seems to function the same in regards to .Equals and ==.

The research that I've done on it in the past really comes to specifics but for most cases, they return the same value. I'll do some more research because I know that both are interchangeable a lot of the time but you are also supposed to use == at times and .Equals with others depending upon what you are doing.

____
WHY ARE SO MANY PEOPLE BANNED?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo