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. Combobox

Combobox

Scheduled Pinned Locked Moved C#
tutorial
11 Posts 6 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.
  • Y Offline
    Y Offline
    yesu prakash
    wrote on last edited by
    #1

    Hi, How to fill a combobox with avalue from 20-100 Thankyou YPKI

    L R A 3 Replies Last reply
    0
    • Y yesu prakash

      Hi, How to fill a combobox with avalue from 20-100 Thankyou YPKI

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      for(int i = 20; i <= 100; i++)
      {
      comboBox.Items.Add(i.ToString());
      }

      1 Reply Last reply
      0
      • Y yesu prakash

        Hi, How to fill a combobox with avalue from 20-100 Thankyou YPKI

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

        for(int i=20;i<=100;i++) { cmbName.Items.Add(i.ToString()); } Hope this help..

        1 Reply Last reply
        0
        • Y yesu prakash

          Hi, How to fill a combobox with avalue from 20-100 Thankyou YPKI

          A Offline
          A Offline
          AhsanS
          wrote on last edited by
          #4

          I guess what you need is to Set minValue = 20 and maxValue = 100

          Ahsan Ullah Senior Software Engineer MCTS 2.0

          X S 2 Replies Last reply
          0
          • A AhsanS

            I guess what you need is to Set minValue = 20 and maxValue = 100

            Ahsan Ullah Senior Software Engineer MCTS 2.0

            X Offline
            X Offline
            xingselex
            wrote on last edited by
            #5

            how about property of it "Datasource" and "Display Memeber" ? what it use for ? how to use ?

            S 1 Reply Last reply
            0
            • A AhsanS

              I guess what you need is to Set minValue = 20 and maxValue = 100

              Ahsan Ullah Senior Software Engineer MCTS 2.0

              S Offline
              S Offline
              Satish Pai
              wrote on last edited by
              #6

              Hi,    i don't think u can have min value & max value for a combo box Satish Pai B

              X 1 Reply Last reply
              0
              • X xingselex

                how about property of it "Datasource" and "Display Memeber" ? what it use for ? how to use ?

                S Offline
                S Offline
                Satish Pai
                wrote on last edited by
                #7

                Hi,    we can set a datatable to datasource.if u want to fill those numbers to combobox we need to loop & then fill datatable & then assign it to combobox.datasource property. Better to use "combobox1.items.add " & a loop . Display member property is used when we have more no.of columns in a query for ex: -    <b>         SqlCommand cmm = new SqlCommand();                   cmm.CommandText = "select Emp_Id,Emp_Name,Emp_Address from Employee";                   cmm.CommandType = CommandType.Text;                   cn.open();                   cmm.Connection = cn;                   DataTable dt = new DataTable();                   SqlDataAdapter sqldt = new SqlDataAdapter(cmm);                   sqldt.Fill(dt);                   comboBox1.DataSource = dt;                   comboBox1.DisplayMember = "Emp_Name";                   comboBox1.ValueMember = "Emp_Id";                   cn.close();</b> While Displaying it Displays employees Name & if u are going to save it in table then we can use "comboBox1.selectedvalue" property were we get the Emp_Id

                1 Reply Last reply
                0
                • S Satish Pai

                  Hi,    i don't think u can have min value & max value for a combo box Satish Pai B

                  X Offline
                  X Offline
                  xingselex
                  wrote on last edited by
                  #8

                  i don understand what u mean "min value & max value" ? however i think that in my combo box just store some string values n id. and i want to ask u a bit more... does combo box can store more then 2 colume or fields. for eg: Emp_ID, Emp_Name, Emp_Gender,Emp_Phone.. ?

                  S 1 Reply Last reply
                  0
                  • X xingselex

                    i don understand what u mean "min value & max value" ? however i think that in my combo box just store some string values n id. and i want to ask u a bit more... does combo box can store more then 2 colume or fields. for eg: Emp_ID, Emp_Name, Emp_Gender,Emp_Phone.. ?

                    S Offline
                    S Offline
                    Satish Pai
                    wrote on last edited by
                    #9

                    No Combo Box can store only 2 columns by 2 Properties 1.DisplayMember - This does the work a displaying a column 2.ValueMember - This does a work what value should be returned when a particular item is choose d. Ex:- EmpID EMP_Name 1 abc 2 def 3 xyz when u select a Emp_name - "def" from combo box & if u use "combobox1.selectedvalue" then it returns 2 or if u select "xyz " then it returns 3 doesn't mind if u still didn't get it.Just reply for doubts.

                    X 1 Reply Last reply
                    0
                    • S Satish Pai

                      No Combo Box can store only 2 columns by 2 Properties 1.DisplayMember - This does the work a displaying a column 2.ValueMember - This does a work what value should be returned when a particular item is choose d. Ex:- EmpID EMP_Name 1 abc 2 def 3 xyz when u select a Emp_name - "def" from combo box & if u use "combobox1.selectedvalue" then it returns 2 or if u select "xyz " then it returns 3 doesn't mind if u still didn't get it.Just reply for doubts.

                      X Offline
                      X Offline
                      xingselex
                      wrote on last edited by
                      #10

                      does combo box control can show 2 column in its dropdownlist ?

                      S 1 Reply Last reply
                      0
                      • X xingselex

                        does combo box control can show 2 column in its dropdownlist ?

                        S Offline
                        S Offline
                        Satish Pai
                        wrote on last edited by
                        #11

                        No Not possible.

                        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