如果我将一个项目添加到数据绑定组合框(通过添加到数据库并刷新TableAdapter),然后如何选择新添加的项目?如何在数据绑定组合框中选择新添加的项目?
Private Sub button_Click(etc etc) etc
Dim frm As New FormName()
frm.ShowDialog()
'On this form I add an entry to the database
If frm.DialogResult = Windows.Forms.DialogResult.OK Then
'Refill TableAdapter
'Now I want to select the new item!
Combo.SelectedText = frm.TextBox.Text 'doesn't work - what's the best way to do this?
End If
End Sub
这不仅仅是最后一个索引,因为组合框项按字母顺序排序,它可能在列表中的任何位置。
这不是一个Web应用程序,只是普通的Windows窗体。无论如何感谢 – Sparrowhawk
好的。但我认为可以采用类似的流程逻辑。我很久没有使用表格适配器,但它应该会给你一个成功的回调。发生该事件时,请设置您先前保存的ID。 – Steven