Another three state boolean - MSDN



  • Disclaimer: This is another three state boolean, not really a WTF I suppose, but I had a good chuckle when I looked this up on MSDN today. This is nowhere near useful in the project I am doing... But MAYBE someone else would need it?

    From http://msdn2.microsoft.com/en-gb/library/system.windows.controls.primitives.togglebutton.ischecked.aspx:

    "A control that inherits from ToggleButton determines its behavior when this property is a null reference (Nothing in Visual Basic).

    CheckBox

    When the IsThreeState property is set to true, a user can click a CheckBox to pick three possible states. The following table describes the three states of a CheckBox.

    <!---->

    State of the CheckBox

    Value of IsChecked

    Checked

    true

    Unchecked

    false

    Indeterminate

    a null reference (Nothing in Visual Basic)

    If IsThreeState is false, you can still programmatically set this property to a null reference (Nothing in Visual Basic) to put the CheckBox in an indeterminate state, but the user cannot set the CheckBox to the indeterminate state through the user interface (UI).

    <SCRIPT type=text/Javascript> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl19a857d7f,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl19img,"; </SCRIPT> Example:

    The following example creates a CheckBox set to an indeterminate state.

    XAML
     <CheckBox Name="checkBox1" IsThreeState="True" IsChecked="{x:Null}">
      A CheckBox in an indeterminate state
    </CheckBox>"


  • Ok, the real WTF is that I cannot edit my own post to try and take out the gibberish...

    Sorry about that, doesn't appear in the compose tab...



  • You may not find it useful, but it is incredibly useful in situations where you want to visually expose a boolean search condition. Allowing someone to search for "all true", "all false", or "all", corresponding to the states checked, not checked and indeterminate is both more intuitive and more useful than having two checkboxes: one for "search on this field", and another for true/false.



  • Uh, I think checkboxes can be 'gray' as in "few" shows up when you select multiple files with different readonly properties for example.

    More like "yes", "no", "some" then :)



  • @Welbog said:

    You may not find it useful, but it is incredibly useful in situations where you want to visually expose a boolean search condition. Allowing someone to search for "all true", "all false", or "all", corresponding to the states checked, not checked and indeterminate is both more intuitive and more useful than having two checkboxes: one for "search on this field", and another for true/false.

     That'd be a horrible GUI. That's what comboboxes are for, to hold more than two values.

    I don't know how you'd use a checkbox to toggle between searching for male/female/both and explain it to the user adequately. Checked = male, unchecked = female, non-checked = both? No thanks. Comboboxes do that just fine, with three values (Both, Men, Women). 



  • Plus, as I have already said, I am not debating the usefulness... Just pointing it out, hoping someone else gets a giggle out of it...



  • @Nandurius said:

    @Welbog said:

    You may not find it useful, but it is incredibly useful in situations where you want to visually expose a boolean search condition. Allowing someone to search for "all true", "all false", or "all", corresponding to the states checked, not checked and indeterminate is both more intuitive and more useful than having two checkboxes: one for "search on this field", and another for true/false.

     That'd be a horrible GUI. That's what comboboxes are for, to hold more than two values.

    I don't know how you'd use a checkbox to toggle between searching for male/female/both and explain it to the user adequately. Checked = male, unchecked = female, non-checked = both? No thanks. Comboboxes do that just fine, with three values (Both, Men, Women). 

    Well, yeah. Male/female may be a boolean in a database, but that's not what I mean. I mean when you're searching on a field like "Product is breakfast". Checked means you want all products that are breakfast, unchecked means you want all products that are not, and the greyed-out state is for when you don't care which it is. When you're populating a combo box with Yes, No and Both, then you really ought to be using a three-state checkbox, as it is more visually clear.


  • @Welbog said:

    When you're populating a combo box with Yes, No and Both, then you really ought to be using a three-state checkbox, as it is more [b]confusing for the end user[/b].
    There, fixed that for ya.



  • @Daid said:

    @Welbog said:
    When you're populating a combo box with Yes, No and Both, then you really ought to be using a three-state checkbox, as it is more [b]confusing for the end user[/b].
    There, fixed that for ya.

     

    Well said. The checkbox would be ridiculous IMHO.



  • I disagree. While I can easily come up with GUIs with confusing three-state checkboxes, I can also easily think up situations in which they would be the most clear component to use.



  • @Welbog said:

    I disagree. While I can easily come up with GUIs with confusing three-state checkboxes, I can also easily think up situations in which they would be the most clear component to use.

     

    Right but the examples that have been provided would not be valid situations to use this. That is all we can react upon.

    But you are arguing an invisible audience anyway... no one debates the usefulness of three state checkboxes... it was simply an observation of where else three state 'booleans' are used. Because they are funny...



  • I think I've seen this before (e.g. file permissions dialog, Explorer-style tree of options) where the third state is only ever set by the program, and essentially means "somewhere in between".  Clicking on it changes it to checked, at which point it effectively becomes a simple checked/unchecked toggle.

     



  • I think MS wants people to use Indeterminate as null.

     

    In the DataGridViewCheckBoxColumn, you can set the TrueValue, FalseValue, and IndeterminateValue.

    Imagine a lame db table field where you have 1, 0, or null/empty.  Thanks to the binding DataGridView.DataSource allows, you can pull in 1/0/null and have them map to check/unchecked.  Whenever the user changes the button's state, the control maps the data back to the bound source so the db can be updated.

     

    This may be poorly explained, but MS wanted .NET 2.0 to be really enterprisey. 



  • @Seltsam said:

    I think MS wants people to use Indeterminate as null.

     

    In the DataGridViewCheckBoxColumn, you can set the TrueValue, FalseValue, and IndeterminateValue.

    Imagine a lame db table field where you have 1, 0, or null/empty.  Thanks to the binding DataGridView.DataSource allows, you can pull in 1/0/null and have them map to check/unchecked.  Whenever the user changes the button's state, the control maps the data back to the bound source so the db can be updated.

     

    Well considering databases have a value of null available to them... I would sure hope a control meant to view/edit their data would be able to handle a null value...

    Otherwise you would need to override it's item rendering event and parse out nulls. That would just be dumb.

    @Seltsam said:

    but MS wanted .NET 2.0 to be really enterprisey. 

    Really? I can't imagine why!



  • I think it's stupid, too.  I was just relaying extra stupidity.



  • For those not in the know, the three state behaviour is straight from win32 (and has prolly in there since the 80's), it's not a VBism.

     Of course the real WTF in .net is that it still has static text windows that need "\r\n" sequences to get a newline.



  • Indeed. Situations such as user rights management spring to mind, where the indeterminate state means as much as 'inherited from ---'. It's an easy way to graphically present inherited user rights from usergroups, higher levels in a rights architecture, etc. etc.



  • I think the only problem with this concept is that it's misnamed.  That's why it drives us nuts.  It's not a checkbox.  It's a Schroedinger's Box. 

     DUH!
     



  • you all laugh now.... but when trinary logic comes to bear...

    haha... Binary digit = bit.

    Trinary digit = ... tit?



  • @GeneWitch said:

    you all laugh now.... but when trinary logic comes to bear...

    haha... Binary digit = bit.

    Trinary digit = ... tit?

    Nope, trits



  • I want to see a checkbox-like control that returns one nat of information (about 1.44 bits).



  • Nope, sorry, I won't be needing this.  Supposedly, I am unemployed ;-)

    Finally, this poor WTF got a response!



  • Tristate checkboxes are a very old concept, at least 17 years old. I can't remember of having seen them ever in a real-world program, though. Must be a reason for that.



  • We actually use them on my project.  For various flags on certain events, you can specify "YES," "NO," "UNSCORED," or "UNDER INVESTIGATION," specifying that the value of that flag is under investigation or undecided.  The value of the field doesn't mean anything until it gets approved (aka becomes "YES" or "NO").

    I know it's not much, but it's something. 



  • @TunnelRat said:

    Nope, sorry, I won't be needing this.  Supposedly, I am unemployed ;-)

    Finally, this poor WTF got a response!

    What, the 20 replies above yours, made back in Feb when it was first posted?




  • @asuffield said:

    I want to see a checkbox-like control that returns one nat of information (about 1.44 bits).

    So a 1.44MB floppy disk is actually 8 Mega nats? The size finally makes sense. I coin the term "Nyte" to be 8 nats, we can have a byte equivalent. The would make a floppy disk 1 MegaNyte.

     



  • @Quinnum said:

    @TunnelRat said:

    Nope, sorry, I won't be needing this.  Supposedly, I am unemployed ;-)

    Finally, this poor WTF got a response!

    What, the 20 replies above yours, made back in Feb when it was first posted?


     

    Hey, you are assuming TR is smart enough to be able to use the forum software...

     

    BIG assumption, and based on no factual evidence, might I add.

     

    ;-) 



  • @Quinnum said:

    @TunnelRat said:

    Nope, sorry, I won't be needing this.  Supposedly, I am unemployed ;-)

    Finally, this poor WTF got a response!

    What, the 20 replies above yours, made back in Feb when it was first posted?

    I sometimes wonder whether TunnelRat is a complete idiot or he's a Kaufman-esque comedic genius operating on a level far, far beyond us.  I'm leaning toward the former.



  • @Thief^ said:

    @asuffield said:

    I want to see a checkbox-like control that returns one nat of information (about 1.44 bits).

    So a 1.44MB floppy disk is actually 8 Mega nats? The size finally makes sense. I coin the term "Nyte" to be 8 nats, we can have a byte equivalent. The would make a floppy disk 1 MegaNyte.

    1 MegaNyte is defined as the amount of code you have to write in order to earn enough money to go out and get smashed for one night.

     

    No, wait, that's a WeekNyte.
     



  • @ammoQ said:

    Tristate checkboxes are a very old concept, at least 17 years old. I can't remember of having seen them ever in a real-world program, though.

    Windows Explorer. Highlight more than one file (some of which are read-only, others not) and right click > properties. Observe the read-only checkbox.

    Does that count?



  • Actually, I've seen this quite often where the chrckbox loads as 'null' and has been styled in a way such that the first click displays a checkmark, the second displays an X and so on, alternating from check to X and back.  The main point is that the form validates that field on a non-null value so that the user is required to explicity click on the box.  Keep in mind though, I haven't seen that use since the win95 days...Come to think of it, I remember a program called BitTerm(sp?) by Cheyenne software that used that in the initial config (I think to select whether your modem was Hayes-compatible or not, among other things)

     I know most programmers out there will scream about how wrong a tri-state boolean is and blah-blah-blah.  I agree.  A true boolean should only be true or false.  Therefore, while attempting to store three states from a checkbox into a two-state (boolean) variable is wrong and stupid, the existence if a three-state checkbox, if stored as another datatype (1 bit signed int comes to mind), is perfectly logical and does have a place, if used properly



  • @PJH said:

    @ammoQ said:

    Tristate checkboxes are a very old concept, at least 17 years old. I can't remember of having seen them ever in a real-world program, though.

    Windows Explorer. Highlight more than one file (some of which are read-only, others not) and right click > properties. Observe the read-only checkbox.

    Does that count?

    Not really. I'm only thinking of checkboxes where users can circle through three different states.

    Edit: maybe I should try the explorer thing first... Looks like I might be making a fool of myself right now. 



  • @Thief^ said:

    @asuffield said:

    I want to see a checkbox-like control that returns one nat of information (about 1.44 bits).

    So a 1.44MB floppy disk is actually 8 Mega nats? The size finally makes sense. I coin the term "Nyte" to be 8 nats, we can have a byte equivalent. The would make a floppy disk 1 MegaNyte.

     

    Sounds like a Marvel Comics bad guy.



  • @ammoQ said:

    @PJH said:

    @ammoQ said:

    Tristate checkboxes are a very old concept, at least 17 years old. I can't remember of having seen them ever in a real-world program, though.

    Windows Explorer. Highlight more than one file (some of which are read-only, others not) and right click > properties. Observe the read-only checkbox.

    Does that count?

    Not really. I'm only thinking of checkboxes where users can circle through three different states.

    Edit: maybe I should try the explorer thing first... Looks like I might be making a fool of myself right now. 

    Indeed. There are three states - checked, unchecked and checked but greyed. And all three can be cycled through.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.