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


Log in to reply
 

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