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. Visual Basic
  4. help combobox

help combobox

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
5 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.
  • E Offline
    E Offline
    Evalee
    wrote on last edited by
    #1

    may i know the way to fill the data from database to the combobox? for datagrid the code is datagridname.setDataBinding(dsStu, "StuTable") then how about the combobox?

    D J K 3 Replies Last reply
    0
    • E Evalee

      may i know the way to fill the data from database to the combobox? for datagrid the code is datagridname.setDataBinding(dsStu, "StuTable") then how about the combobox?

      D Offline
      D Offline
      Dave Sexton
      wrote on last edited by
      #2

      Create & fill a dataset object then use the combobox's DataSource and DisplayMember properties display data from the dataset.

      E 1 Reply Last reply
      0
      • D Dave Sexton

        Create & fill a dataset object then use the combobox's DataSource and DisplayMember properties display data from the dataset.

        E Offline
        E Offline
        Evalee
        wrote on last edited by
        #3

        thanks. kulazfuk

        1 Reply Last reply
        0
        • E Evalee

          may i know the way to fill the data from database to the combobox? for datagrid the code is datagridname.setDataBinding(dsStu, "StuTable") then how about the combobox?

          J Offline
          J Offline
          Janani Divya
          wrote on last edited by
          #4

          Here is one way of binding data in combo box: In code behind: Dim ds As New DataSet ds = class_Ratetype.ComboRateDisplay() Dim dvs As New DataView(ds.Tables(0)) If dvs.Count > 0 Then Me.ComboRoomType.DataSource = dvs Me.ComboRoomType.DisplayMember = "Roomtype" Me.ComboRoomType.ValueMember = "Roomtype_Id" End If End Sub Class file content for this: Public Function ComboRateDisplay() As DataSet Dim constr As String = SqlHelper.GetConnectionString() Dim conn As New SqlConnection(constr) Dim cmdSQL As New SqlCommand("SP_COMBORATEDISPLAY", conn) Dim da As New SqlDataAdapter Dim ds As New DataSet Dim dv As New DataView cmdSQL.CommandType = CommandType.StoredProcedure conn.Open() da.SelectCommand = cmdSQL da.Fill(ds, "TBL_Roomtype") ComboRateDisplay = ds.Copy da.Dispose() If (Not conn Is Nothing) Then conn.Close() conn.Dispose() End If GC.Collect() End Function For ur reference: class_Ratetype ---> object for class file ComboRoomType ----> combobox name Roomtype ----> Display member Roomtype_Id ----> Value member SP_COMBORATEDISPLAY --> Stored procedure TBL_Roomtype ----> Table name Janani

          1 Reply Last reply
          0
          • E Evalee

            may i know the way to fill the data from database to the combobox? for datagrid the code is datagridname.setDataBinding(dsStu, "StuTable") then how about the combobox?

            K Offline
            K Offline
            Kschuler
            wrote on last edited by
            #5

            I always do it like this: comboBox1.DataSource = dtTable comboBox1.DisplayMember = "FieldToDisplay" comboBox1.ValueMember = "FieldContainingValue"

            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