Thread: how to select on the valid listview items?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    40

    how to select on the valid listview items?

    Hi guys,

    Can you please help me with my listview items. I want to know that when a user select the items on the listview to tick and untick on the checkboxes while a user do not select on the other listview items, how do the program suppose to know which listview items that a user have selected after tick and untick on the checkboxes?

    Something like this:

    Code:
    for each (ListViewItem ^checkeditems in listView1::SelectedItems)
    {
    	if (checkeditems->Selected == true)
    	{
    	 if (checkeditems->Checked == true)
    	 {
    		checkeditems->Selected = false;
    	 }
    	 else if (checkeditems->Checked == false)
    	 {
    		MessageBox::Show(checkeditems->SubItems[1]->Text);
    	 }
    	}
    }
    I need to know how to do this because I want to send the information of substring text to my php server.

    If you know how i can do this, I would be very grateful.

    Thanks,
    Mark

  2. #2
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Code:
    (checkeditems->Selected == true)
    Whenever you write "== true", god kills a sweet innocent kitten. You monster!

    Seriously though, nobody has even the slightest chance of helping you unless you tell us what GUI framework this is.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Neo1 View Post
    Whenever you write "== true", god kills a sweet innocent kitten. You monster!
    If checkeditems->Selected is declared as "bool" that seems perfectly reasonable IMO.

  4. #4
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Subsonics View Post
    If checkeditems->Selected is declared as "bool" that seems perfectly reasonable IMO.
    No, "== true" is never reasonable.

    Code:
    (checkeditems->Selected == true)
    Is equivalent to:

    Code:
    (checkeditems->Selected)
    Writing "== true" is basically just another way of saying "i don't know how boolean-expressions work".
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Neo1 View Post
    another way of saying "i don't know how boolean-expressions work".
    if it's a nullable bool, then "== true" is a perfectly valid expression, because System::Nullable<bool> doesn't implicitly convert to bool, but it does have an overloaded equality operator.

  6. #6
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Elkvis View Post
    if it's a nullable bool, then "== true" is a perfectly valid expression, because System::Nullable<bool> doesn't implicitly convert to bool, but it does have an overloaded equality operator.
    What's your point? The code in question is pseudo-code, we obviously aren't talking about nullables or tribools or whatever. My point still stands, using "== true" in a boolean expression is fundamentally wrong. You found an exception to this rule, have some cake.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  7. #7
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Neo1 View Post
    No, "== true" is never reasonable.

    Code:
    (checkeditems->Selected == true)
    Is equivalent to:

    Code:
    (checkeditems->Selected)
    Writing "== true" is basically just another way of saying "i don't know how boolean-expressions work".
    So what, it comes down to opinion. You don't think it's reasonable because there is an equivalent short hand available, it's nothing wrong with explicitly typing it out. The short hand buys you nothing.

  8. #8
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    i prefer
    Code:
    (! checkeditems->Selected != true)
    just to make people wonder
    Kurt

  9. #9
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Subsonics View Post
    So what, it comes down to opinion. You don't think it's reasonable because there is an equivalent short hand available, it's nothing wrong with explicitly typing it out. The short hand buys you nothing.
    Wrong, my version is not shorthand for anything. There is something wrong with writing out " == true", if your expression evaluates to true, you don't then have to compare it to true, that's not the right way, that's stupid.

    You're essentially asking your computer to compare true to true, or true to false.

    The short hand buys you nothing.
    How does "true == true" buy you anything?

    Do you also write:

    Code:
    if( x > 5 == true)
    And would you consider:
    Code:
    if(x > 5)
    ..to be short hand?
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  10. #10
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    What is extremely poor, redundant etc. will vary depending on who you ask.

  11. #11
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Subsonics View Post
    What is extremely poor, redundant etc. will vary depending on who you ask.
    Boolean algebra is extremely well-defined, and you will find it is possible to mathematically prove what is redundant and what is not.

    Fortunately, writing code is a science, more than it is an art.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  12. #12
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Neo1 View Post
    Boolean algebra is extremely well-defined, and you will find it is possible to mathematically prove what is redundant and what is not.
    So what, C is not boolean algebra. What about descriptive variable and function names, or comments. Redundant?
    Last edited by Subsonics; 05-06-2012 at 12:03 PM.

  13. #13
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Subsonics View Post
    So what, C is not boolean algebra. What about descriptive variable and function names, or comments. Redundant?
    Hey man, you're the one defending the use of an extra comparison for purposes of styling. I'm all for descriptive names. Anything else would be wrong.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  14. #14
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Neo1 View Post
    Hey man, you're the one defending the use of an extra comparison for purposes of styling. I'm all for descriptive names. Anything else would be wrong.
    Writing out "== true" does not result in a extra comparison. The comparison is made anyway but implicitly.

  15. #15
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    how is any of this related to the OP's question?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. keeping track of listview items
    By Bleech in forum Windows Programming
    Replies: 0
    Last Post: 08-31-2006, 09:11 PM
  2. questions regarding listview items
    By Bleech in forum Windows Programming
    Replies: 7
    Last Post: 08-26-2006, 02:26 PM
  3. Moving items in a ListView
    By Cactus_Hugger in forum Windows Programming
    Replies: 1
    Last Post: 01-18-2006, 09:40 PM
  4. ListView Items
    By Smoose777 in forum C# Programming
    Replies: 1
    Last Post: 06-21-2003, 12:10 PM
  5. Selected Items in a ListView
    By Lowas in forum Windows Programming
    Replies: 12
    Last Post: 09-01-2001, 07:17 PM