我有一个带有 2 个列表框的表单。在这里,listbox1 填充了演员的姓名。如果从 listbox1 中选择了一个名称,则 listbox2 应该显示涉及该名称的电影的标题。如果选择了另一个名称,listbox2 将显示涉及该名称的电影的标题。
Call Connect()
With Me
STRSQL = "select mTitle from selectmovie where cName = '" & lstNames.SelectedItem & "'"
Try
myCmd.Connection = myConn
myCmd.CommandText = STRSQL
myReader = myCmd.ExecuteReader
If (myReader.Read()) Then
myReader.Close()
myAdptr.SelectCommand = myCmd
myAdptr.Fill(myDataTable)
lstTitle.DisplayMember = "mTitle"
lstTitle.ValueMember = "mTitle"
If myDataTable.Rows.Count > 0 Then
For i As Integer = 0 To myDataTable.Rows.Count - 1
lstTitle.Items.Add(myDataTable.Rows(i)("mTitle"))
Next
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End With
没有错误。当我选择 1 项时,结果是正确的,但它留下了很多空间..这里是我的表单的屏幕截图:http: //www.flickr.com/photos/92925726@N06/8445945758/in/photostream/
当我选择actor3时输出变得更糟:http: //www.flickr.com/photos/92925726@N06/8445945724/in/photostream/