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. Can anyone help me ?

Can anyone help me ?

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
7 Posts 3 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.
  • E Offline
    E Offline
    eni_94
    wrote on last edited by
    #1

    I wanna know how to add an item to a combobox from a textbox by clicking a button. I usually use C# so i'd prefer to finish what i'm doing in C#. thanx.

    M G 2 Replies Last reply
    0
    • E eni_94

      I wanna know how to add an item to a combobox from a textbox by clicking a button. I usually use C# so i'd prefer to finish what i'm doing in C#. thanx.

      M Offline
      M Offline
      Matthew Cuba
      wrote on last edited by
      #2

      Won't myNiftyComboBox.Items.Add(myVerySpecialTextBox.Text); do the trick? Regards, Matt

      It isn't enough to do well in life. One must do good when and where one can. Otherwise, what's the point?

      E 1 Reply Last reply
      0
      • E eni_94

        I wanna know how to add an item to a combobox from a textbox by clicking a button. I usually use C# so i'd prefer to finish what i'm doing in C#. thanx.

        G Offline
        G Offline
        goldoche
        wrote on last edited by
        #3

        Try something like: comboBox1.Items.Add(textBox1.Text);

        E 2 Replies Last reply
        0
        • G goldoche

          Try something like: comboBox1.Items.Add(textBox1.Text);

          E Offline
          E Offline
          eni_94
          wrote on last edited by
          #4

          thanx a lot ,it works

          1 Reply Last reply
          0
          • M Matthew Cuba

            Won't myNiftyComboBox.Items.Add(myVerySpecialTextBox.Text); do the trick? Regards, Matt

            It isn't enough to do well in life. One must do good when and where one can. Otherwise, what's the point?

            E Offline
            E Offline
            eni_94
            wrote on last edited by
            #5

            thanx a lot

            1 Reply Last reply
            0
            • G goldoche

              Try something like: comboBox1.Items.Add(textBox1.Text);

              E Offline
              E Offline
              eni_94
              wrote on last edited by
              #6

              that worked but when i open the program i add an item, if i restart the program the new item isn't there anymore...

              G 1 Reply Last reply
              0
              • E eni_94

                that worked but when i open the program i add an item, if i restart the program the new item isn't there anymore...

                G Offline
                G Offline
                goldoche
                wrote on last edited by
                #7

                There may be other ways, but here's what I would do: - Create a Serializable class with an array of strings as a member. - When you close your application, create an instance of this class and copy your comboBox items into the string array of your class. - Then, serialize your class in to file. Finally, when you start your application, deserialize your class, and use comboBox1.Items.Clear(); comboBox1.Items.AddRange(myCustomClassInstance.StringArray); You will find plenty of information and tutorials about serialization on the web. Cheers

                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