datagridview (Mydgv1)가 런타임에 만들어집니다. 첫 번째 열은 편집 가능한 콤보 상자 열입니다. 디스플레이 멤버 및 값 멤버를 설정했지만 올바른 디스플레이/값 멤버를 가져올 수 없습니다. 드롭 다운에서 항목을 선택할 때 값/표시 멤버의 값을 드롭 다운의 마지막 항목의 값/표시 멤버로 가져옵니다. 값/표시 멤버가 선택한 항목으로 변경되지 않는 이유는 무엇입니까? 콤보 상자 열.콤보 상자의 선택된 인덱스로 표시/값 멤버가 변경되지 않습니다.
On Form Load Event
combo.HeaderText = "Item"
combo.Name = "itemid"
combo.Items.Clear()
Dim ds As SqlDataReader
Dim cmm As New SqlCommand("select itemid from itemdesc", con)
con.Open()
ds = cmm.ExecuteReader
If ds.HasRows Then
While ds.Read
combo.Items.Add(ds(0).ToString)
combo.ValueMember = ds("itemid")
combo.DisplayMember = ds("itemid")
End While
End If
con.Close()
Mydgv1.Columns.Add(combo)
On comboboxcolumn's Leave Event
it = combo.DisplayMember
MsgBox(it)
당신이 combobox.Leave 이벤트 또는 combobox.selectedIndexChanged 이벤트 사용을 검색의 SelectedIndexChanged 이벤트를 사용하지 않는? – Markus
Markus, combo box leave event를 사용하고 있습니다. selectedIndexChanged 이벤트를 사용해야합니까? –