Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
Please help! How can i get value from Cell comboBox on seleted of grid.
and i display both field is displayMember and DisplayValue and i use this code on gird cell click to fill Cell comboBox
VB
If (e.ColumnIndex = 2 And e.RowIndex > -1) Then
            Dim dt2 As New DataTable
            ' For i As Integer = 0 To grdTrackSubItem.RowCount - 1
            cmbTCTackName = New DataGridViewComboBoxCell
            dt2 = dataHandler.Filldatatable("SELECT Id, TrackName FROM  MasterTrackSet WHERE (IsDelete=0 or IsDelete IS NULL) AND TrackSet='" & grdTrackSubItem.Item("CmbTrackSet", e.RowIndex).Value.ToString.Trim & "'")
            cmbTCTackName.DataSource = dt2
            cmbTCTackName.DisplayMember = dt2.Columns("TrackName").ToString
            cmbTCTackName.ValueMember = dt2.Columns("Id").ToString
            grdTrackSubItem(3, e.RowIndex) = cmbTCTackName
            ' Next
        End If
Posted
Updated 19-May-11 11:12am
v2

1 solution

VB
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
       Dim x As ComboBox
       x = e.Control

       AddHandler x.SelectedIndexChanged, AddressOf ValeChanged
   End Sub

   Private _value As Integer

   Private Sub ValeChanged(ByVal sender As System.Object, ByVal e As EventArgs)

       _value = CType(sender.selecteditem, Integer)
       MessageBox.Show(_value)

   End Sub
 
Share this answer
 
Comments
raviprajapat 20-May-11 8:55am    
_value = CType(sender.selecteditem, Integer) <-----
here i get this error
Conversion from type 'DataRowView' to type 'Integer' is not valid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900