Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox value not holding

Status
Not open for further replies.

dinster

Programmer
Joined
Apr 12, 2007
Messages
54
Location
GB
Hi everyone i've managed to populate a combobox and also show it on datagrid. I had good example from this site


However am kind of stuck on a new problem. when i select the combobox and pick a value it does not hold in the datagrid.
when i click on another cell it goes back to what the value was before.

the Code i've got so far is this....

Code:
 Dim sql As String

        '
        sql = "SELECT Drug_ID, DrugName "
        sql = sql + "FROM R_Drugs "
        sql = sql + "ORDER BY DrugName;"

        Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(connectionstring)
        Dim mycmd As New OleDb.OleDbCommand(sql, conn)
        Dim myadapter As New OleDb.OleDbDataAdapter(mycmd)
        Dim dsresults As New DataSet
        Dim dtresults As DataTable = dsresults.Tables.Add("DrugIDS")
        Dim recordcount As Integer


        myadapter.Fill(dsresults, "DrugIDS")
        recordcount = dtresults.Rows.Count


        Dim cs1 As New CGridComboBoxStyle("Drug_ID")



        With cs1
            .Width = 200
            .Alignment = HorizontalAlignment.Left
            .HeaderText = "Drug_ID"
            .NullText = ""
            .cgCombo.DisplayMember = "DrugIDS.DrugName"
            .cgCombo.ValueMember = "DrugIDS.Drug_ID"
            .cgCombo.DataSource = dsresults
            .cgCombo.DropDownStyle = ComboBoxStyle.DropDownList

        End With


        CGrid.AddColumn(ts, cs1)


        'Set an AlternatingBackColor - just for looks
        ts.AlternatingBackColor = Color.LightGoldenrodYellow

        'Set the TableStyle for the Grid
        CGrid.SetGridStyle(Me.DataGrid1, dt, ts)

Could some1 provide me to an insight on how to go bout this. It would really help?

many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top