Checkbox & CheckedChanged event... really?
-
When the CheckedChanged event fires, why does e not have a property with the current state? A CheckedListbox does... Am I missing something here? private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)... >>e has 'currentValue' and 'newValue'<< private void checkBox1_CheckedChanged(object sender, EventArgs e)... >>e has doesn't<< Do I really have to go get the state from the checkbox when I'm already in the state event fired by that checkbox? (checkBox1 == true) That seems redundant. Thanks.
-
When the CheckedChanged event fires, why does e not have a property with the current state? A CheckedListbox does... Am I missing something here? private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)... >>e has 'currentValue' and 'newValue'<< private void checkBox1_CheckedChanged(object sender, EventArgs e)... >>e has doesn't<< Do I really have to go get the state from the checkbox when I'm already in the state event fired by that checkbox? (checkBox1 == true) That seems redundant. Thanks.
BDJones wrote:
Do I really have to go get the state from the checkbox
yes
BDJones wrote:
if (checkBox1 == true) ...
no
if (checkBox1.Checked) ...
:)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
When the CheckedChanged event fires, why does e not have a property with the current state? A CheckedListbox does... Am I missing something here? private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)... >>e has 'currentValue' and 'newValue'<< private void checkBox1_CheckedChanged(object sender, EventArgs e)... >>e has doesn't<< Do I really have to go get the state from the checkbox when I'm already in the state event fired by that checkbox? (checkBox1 == true) That seems redundant. Thanks.
The reason the checkedlistbox passes the state is because there are any number of individual checkboxes which may be checked/unchecked. A single checkbox is passed to you in the event
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkBox = (CheckBox)sender;
if(chkBox.Checked) ...
} -
The reason the checkedlistbox passes the state is because there are any number of individual checkboxes which may be checked/unchecked. A single checkbox is passed to you in the event
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkBox = (CheckBox)sender;
if(chkBox.Checked) ...
} -
BDJones wrote:
Do I really have to go get the state from the checkbox
yes
BDJones wrote:
if (checkBox1 == true) ...
no
if (checkBox1.Checked) ...
:)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
The reason the checkedlistbox passes the state is because there are any number of individual checkboxes which may be checked/unchecked. A single checkbox is passed to you in the event
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkBox = (CheckBox)sender;
if(chkBox.Checked) ...
}