0

I have a sub like this:

Public Sub Populate(ByVal DataGridView As DataGridView, ByVal bs As BindingSource, ByRef bsPositions As BindingSource)

    Dim ds As New DataSet

    Using cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=demo.mdb;")

                    Dim da As New OleDbDataAdapter("SELECT DISTINCT BIDUSER_PI_CAB_TEMP.MEIO, BIDUSER_SUBMEIO.DS_SUBMEIO " & _
                                       " FROM (BIDUSER_PI_CAB_TEMP LEFT JOIN BIDUSER_SUBMEIO ON " & _
                                       " BIDUSER_PI_CAB_TEMP.ID_SUBMEIO = BIDUSER_SUBMEIO.ID_SUBMEIO) " & _                                           " LEFT JOIN BIDUSER_MEIO ON BIDUSER_SUBMEIO.ID_MEIO = BIDUSER_MEIO.ID_MEIO " & _
                                       " WHERE (((BIDUSER_PI_CAB_TEMP.STATUS_PI)<>'CANCELADO'))", cn)

        da.Fill(ds, "Names")
        da = New OleDbDataAdapter("select ID_SUBMEIO,DS_SUBMEIO from biduser_SUBMEIO " & _
                                       "order by DS_SUBMEIO", cn)
        da.Fill(ds, "PositionType")

    End Using

    Dim PeopleNamesColumn As New DataGridViewTextBoxColumn With
        {
            .DataPropertyName = "MEIO",
            .HeaderText = "MEIO"
        }

    bsPositions.DataSource = ds.Tables("PositionType")


    Dim ContactPositionColumn As New DataGridViewComboBoxColumn With
        {
            .DataPropertyName = "DS_SUBMEIO",
            .DataSource = bsPositions,
            .DisplayMember = "DS_submeio",
            .DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,
            .Name = "SubMeio",
            .HeaderText = "SubMeio",
            .SortMode = DataGridViewColumnSortMode.Automatic,
            .ValueMember = "DS_SUBMEIO"
        }



    DataGridView.AutoGenerateColumns = False

    DataGridView.Columns.AddRange(New DataGridViewColumn() {PeopleNamesColumn, ContactPositionColumn})

    ds.Tables("Names").AcceptChanges()

    bs.DataSource = ds.Tables("Names")
    DataGridView.DataSource = bs
    DataGridView.ExpandColumns()

End Sub

As you can see a data set in the DataGridViewComboBoxColum:

da = New OleDbDataAdapter("select ID_SUBMEIO,DS_SUBMEIO from biduser_SUBMEIO " & _
                                           "order by DS_SUBMEIO", cn)

I need get the value of ID_SUBMEIO when the user choose a value in the Combobox, inside in the Gridview ComboBox Column, or directly from Datasource of DataGridViewComboBoxColum. Do you know how I do this?

0 Answers0