文字が 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