Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Question about list Box

Question about list Box

Scheduled Pinned Locked Moved C / C++ / MFC
question
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zizzzz
    wrote on last edited by
    #1

    I have a combobox in which i have values when i select a value and press button add, I add it to the list box but I want to control this insertion i mean if i insert a value the second time he must don't accept it. how can i do that thank's :zzz: zizzzzzzzzzzz

    K U D 3 Replies Last reply
    0
    • Z zizzzz

      I have a combobox in which i have values when i select a value and press button add, I add it to the list box but I want to control this insertion i mean if i insert a value the second time he must don't accept it. how can i do that thank's :zzz: zizzzzzzzzzzz

      K Offline
      K Offline
      KarstenK
      wrote on last edited by
      #2

      Check whether value is already in the CB.

      Greetings from Germany

      1 Reply Last reply
      0
      • Z zizzzz

        I have a combobox in which i have values when i select a value and press button add, I add it to the list box but I want to control this insertion i mean if i insert a value the second time he must don't accept it. how can i do that thank's :zzz: zizzzzzzzzzzz

        U Offline
        U Offline
        uday kiran janaswamy
        wrote on last edited by
        #3

        Hi, Use combox->FindStringExact(...) Api of the CB. if it is -1 then add the string if it gives any nuber greter than 0 then there is a string. Good Luck.

        Uday kiran

        Z 1 Reply Last reply
        0
        • U uday kiran janaswamy

          Hi, Use combox->FindStringExact(...) Api of the CB. if it is -1 then add the string if it gives any nuber greter than 0 then there is a string. Good Luck.

          Uday kiran

          Z Offline
          Z Offline
          zizzzz
          wrote on last edited by
          #4

          I think that you don't understand my question i'll give you an exemple my combo 0 1 2 3 when I select a value "0" for example and press the button ok it'll be added to the list. I want that when I select this value again it 'll not be added to the listBox because it's already exists. i hope that my explanation is more clear thank's

          U 1 Reply Last reply
          0
          • Z zizzzz

            I think that you don't understand my question i'll give you an exemple my combo 0 1 2 3 when I select a value "0" for example and press the button ok it'll be added to the list. I want that when I select this value again it 'll not be added to the listBox because it's already exists. i hope that my explanation is more clear thank's

            U Offline
            U Offline
            uday kiran janaswamy
            wrote on last edited by
            #5

            what's the problem

            Uday kiran

            Z 1 Reply Last reply
            0
            • U uday kiran janaswamy

              what's the problem

              Uday kiran

              Z Offline
              Z Offline
              zizzzz
              wrote on last edited by
              #6

              I don't want to have in my listBox for example 0 1 0 0 you understand me ? the value 0 must figure one's :~

              U 1 Reply Last reply
              0
              • Z zizzzz

                I don't want to have in my listBox for example 0 1 0 0 you understand me ? the value 0 must figure one's :~

                U Offline
                U Offline
                uday kiran janaswamy
                wrote on last edited by
                #7

                hi, I told na use FistStringExact(...) api which detects the Duplicate Values in the ListBox. //Code......... int i = -1; i = cb->FindStringExact("one"); // one is a String value you want to insert. if(i == -1) { Cb->AddString("one"); } else { MessageBox("Already Exist in the List"); } // end of the Code Whats the Problem.

                Uday kiran

                Z 1 Reply Last reply
                0
                • U uday kiran janaswamy

                  hi, I told na use FistStringExact(...) api which detects the Duplicate Values in the ListBox. //Code......... int i = -1; i = cb->FindStringExact("one"); // one is a String value you want to insert. if(i == -1) { Cb->AddString("one"); } else { MessageBox("Already Exist in the List"); } // end of the Code Whats the Problem.

                  Uday kiran

                  Z Offline
                  Z Offline
                  zizzzz
                  wrote on last edited by
                  #8

                  thank you this is what I want :-D

                  1 Reply Last reply
                  0
                  • Z zizzzz

                    I have a combobox in which i have values when i select a value and press button add, I add it to the list box but I want to control this insertion i mean if i insert a value the second time he must don't accept it. how can i do that thank's :zzz: zizzzzzzzzzzz

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    zizzzz wrote:

                    ...if i insert a value the second time he must don't accept it.

                    First check to make sure the listbox (not the combobox) does not already contain the item. If it does not, call AddString().


                    "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                    "Judge not by the eye but by the heart." - Native American Proverb

                    Z 1 Reply Last reply
                    0
                    • D David Crow

                      zizzzz wrote:

                      ...if i insert a value the second time he must don't accept it.

                      First check to make sure the listbox (not the combobox) does not already contain the item. If it does not, call AddString().


                      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                      "Judge not by the eye but by the heart." - Native American Proverb

                      Z Offline
                      Z Offline
                      zizzzz
                      wrote on last edited by
                      #10

                      yes David I did it and it's working like I want thank's for you and for uday kiran janaswamy

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups