我遇到了在字母完成超过 Combobox.SelectedItem 长度后出现空格的问题。为什么?我该如何解决这个问题?
下面将我的问题显示为一个非常短小的视频。 这是一个小视频
Imports System.Data.SqlClient
Public Class Main
WithEvents bsData As New BindingSource
Dim sConn As New SqlConnection
Dim dt As New DataTable
Dim ds As New DataSet
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
sConn.ConnectionString = "Data Source=PC-N39;Initial Catalog=Esi01;Persist Security Info=True;User ID=sa;Password=sas"
sConn.Open()
Try
Dim myTable As DataTable = New DataTable("MyTable")
myTable.Columns.Add(New DataColumn("Group Code"))
myTable.Columns.Add(New DataColumn("Description"))
myTable.Columns.Add(New DataColumn("NothingSerious"))
Dim cmd As New SqlCommand("Select * from tbUnit", sConn)
Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.Default)
Dim myRow As DataRow
While dr.Read()
myRow = myTable.NewRow
myRow.Item(0) = dr(0)
myRow.Item(1) = dr(1)
myRow.Item(2) = dr(2)
myTable.Rows.Add(myRow)
End While
dr.Close()
Dim myData4 As DataTable = myTable
ds = New DataSet()
ds.Tables.Add(myData4)
MultiColumnCombo1.DisplayMember = "Group Code"
MultiColumnCombo1.DrawMode = DrawMode.OwnerDrawVariable
MultiColumnCombo1.ColumnWidths = "50;150"
MultiColumnCombo1.DataSource = myData4
MultiColumnCombo1.Text = String.Empty
Catch ex As Exception
MsgBox(ex.ToString)
End Try
sConn.Close()
End Sub
End Class