我试图在组合框中显示问题ID,以便在文本框中重现匹配问题。然而,我没有收到所有五个问题ID的问题ID,但是有问题ID的问题:4 |, u/ G& s [- s$ k% b WCInterface.ucQuestions 问题WCInterface.ucQuestions 问题3 J# n) N3 j0 ] 我的代码: A# ~. ?2 R J) N P% ]- ~Private loaded As Boolean = FalsePrivate Sub ucQuestions_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load cmbQuestion.DisplayMember = "Question_ID" cmbQuestion.ValueMember = "Question_ID" cmbQuestion.DataSource = retrieveQuestions() 'when form loads loaded = TrueEnd SubPrivate Sub cmbQuestion_SelectedIndexChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles cmbQuestion.SelectedIndexChanged If (loaded) Then cmbQuestion.DisplayMember = "Question_ID" cmbQuestion.ValueMember = "Question_ID" cmbQuestion.DataSource = Nothing 'Resets data source cmbQuestion.DataSource = retrieveQuestions() 'when form loads End IfEnd SubPublic Function retrieveQuestions() As List(Of Question) Dim typeList As New List(Of Question) Dim Str As String = "SELECT Question_ID,Question_Text FROM Question" Try Using conn As New SqlClient.SqlConnection(DBConnection) conn.Open() Using cmdQuery As New SqlClient.SqlCommand(Str,conn) Using drResult As SqlClient.SqlDataReader = cmdQuery.ExecuteReader() While drResult.Read typeList.Add(New Question(drResult("Question_ID"),drResult("Question_Text"))) End While End Using 'Automatically closes connection End Using End Using Catch ex As Exception MsgBox("Question List Exception: " & ex.Message & vbNewLine & Str) End Try Return typeListEnd Function感谢您提出如何显示问题ID谢谢你的任何建议 2 j$ A1 s3 [& J) B+ ?- e% u$ R * s/ c' Y2 u" Y5 |$ L4 H. D+ C; w 解决方案: