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#
  4. Return a specified item from a list box..

Return a specified item from a list box..

Scheduled Pinned Locked Moved C#
database
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.
  • T Offline
    T Offline
    Tichaona J
    wrote on last edited by
    #1

    Hi I am looking for a way to find an item in a list box by its index number, then copy it to a variable any ideas. Thanks

    OriginalGriffO 1 Reply Last reply
    0
    • T Tichaona J

      Hi I am looking for a way to find an item in a list box by its index number, then copy it to a variable any ideas. Thanks

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Have you tried using it's index number at all?

              ListBox lb = new ListBox();
              lb.Items.Add("Hello");
              lb.Items.Add("Goodbye");
              string s = lb.Items\[1\] as string;
      

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      R 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Have you tried using it's index number at all?

                ListBox lb = new ListBox();
                lb.Items.Add("Hello");
                lb.Items.Add("Goodbye");
                string s = lb.Items\[1\] as string;
        

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        I think you meant lb.Items[0].  :) /ravi

        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

        L 1 Reply Last reply
        0
        • R Ravi Bhavnani

          I think you meant lb.Items[0].  :) /ravi

          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Maybe Griff did mean [1] for "Goodbye", as in "Goodbye. Now go look things up in MSDN and/or learn to use Google and stop bothering everyone with elementary questions like that." :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          R OriginalGriffO 2 Replies Last reply
          0
          • L Luc Pattyn

            Maybe Griff did mean [1] for "Goodbye", as in "Goodbye. Now go look things up in MSDN and/or learn to use Google and stop bothering everyone with elementary questions like that." :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            R Offline
            R Offline
            Ravi Bhavnani
            wrote on last edited by
            #5

            Heh.  But what's obvious to some may not be obvious to others.  Isn't that what learning's all about?  :) /ravi

            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

            L 1 Reply Last reply
            0
            • R Ravi Bhavnani

              Heh.  But what's obvious to some may not be obvious to others.  Isn't that what learning's all about?  :) /ravi

              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Sure, however making some effort yourself can be very rewarding and typically yields more insight. The OP has gotten answers already he clearly is not following up by reading the doc at all. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              1 Reply Last reply
              0
              • L Luc Pattyn

                Maybe Griff did mean [1] for "Goodbye", as in "Goodbye. Now go look things up in MSDN and/or learn to use Google and stop bothering everyone with elementary questions like that." :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                And there was me trying to be subtle... :laugh:

                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                L 1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  And there was me trying to be subtle... :laugh:

                  Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  Too much so, I'm afraid. I felt the need to clarify a little. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                  OriginalGriffO 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    Too much so, I'm afraid. I felt the need to clarify a little. :)

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                    OriginalGriffO Offline
                    OriginalGriffO Offline
                    OriginalGriff
                    wrote on last edited by
                    #9

                    I don't often get told I'm too subtle! Normally it's quite the reverse. It'll be a pipe and carpet slippers next, I'm afraid... :sigh:

                    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                    L 1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      I don't often get told I'm too subtle! Normally it's quite the reverse. It'll be a pipe and carpet slippers next, I'm afraid... :sigh:

                      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #10

                      OriginalGriff wrote:

                      It'll be a pipe and carpet slippers next

                      Now you've lost me, you really need to start formulating more clearly. :laugh:

                      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                      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