C
Cor
Hi all,
I think I do something wrong, but I don't see what.
I have made a sample.
The sample needs only a form with a combobox and this code.
(I can tell you that it took a long time to see this, but it still can be
that I do something stupid).
When I fill a combobox (1) direct, I get after SelectionChangeCommitted the
previous selected item.
When I fill a combobox (2) using a datatable I get after
SelectionChangeCommitted the selected item (The behaviour that I suspected).
This is the text on MSDN about it,
Occurs when the selected item has changed and that change is committed.
Remarks
You can create a SelectionChangeCommitted event handler to provide special
handling for the ComboBox when the user changes the selected item in the
list.
(That did me doubt if I understood it well).
I am curious if I become crazy?
(I could find nothing about it on MSDN).
Cor
\\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 10 To 100 Step 10
Me.ComboBox1.Items.Add(i.ToString)
Next
Me.ComboBox1.SelectedIndex = 5
Dim dt As New DataTable
Dim dc As New DataColumn
Dim dr As DataRow
dc.DataType = System.Type.GetType("System.String")
dc.ColumnName = "i"
dt.Columns.Add(dc)
For i = 1 To 10
dr = dt.NewRow()
dr("i") = (i * 10).ToString
dt.Rows.Add(dr)
Next i
Me.ComboBox2.DisplayMember = "i"
Me.ComboBox2.DataSource = dt
Me.ComboBox2.SelectedIndex = 5
End Sub
Private Sub ComboBox1_SelectionChangeCommitted _
(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
ComboBox1.SelectionChangeCommitted
MessageBox.Show(Me.ComboBox1.Text)
End Sub
Private Sub ComboBox2_SelectionChangeCommitted _
(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
ComboBox2.SelectionChangeCommitted
MessageBox.Show(Me.ComboBox2.Text)
End Sub
///
I think I do something wrong, but I don't see what.
I have made a sample.
The sample needs only a form with a combobox and this code.
(I can tell you that it took a long time to see this, but it still can be
that I do something stupid).
When I fill a combobox (1) direct, I get after SelectionChangeCommitted the
previous selected item.
When I fill a combobox (2) using a datatable I get after
SelectionChangeCommitted the selected item (The behaviour that I suspected).
This is the text on MSDN about it,
Occurs when the selected item has changed and that change is committed.
Remarks
You can create a SelectionChangeCommitted event handler to provide special
handling for the ComboBox when the user changes the selected item in the
list.
(That did me doubt if I understood it well).
I am curious if I become crazy?
(I could find nothing about it on MSDN).
Cor
\\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 10 To 100 Step 10
Me.ComboBox1.Items.Add(i.ToString)
Next
Me.ComboBox1.SelectedIndex = 5
Dim dt As New DataTable
Dim dc As New DataColumn
Dim dr As DataRow
dc.DataType = System.Type.GetType("System.String")
dc.ColumnName = "i"
dt.Columns.Add(dc)
For i = 1 To 10
dr = dt.NewRow()
dr("i") = (i * 10).ToString
dt.Rows.Add(dr)
Next i
Me.ComboBox2.DisplayMember = "i"
Me.ComboBox2.DataSource = dt
Me.ComboBox2.SelectedIndex = 5
End Sub
Private Sub ComboBox1_SelectionChangeCommitted _
(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
ComboBox1.SelectionChangeCommitted
MessageBox.Show(Me.ComboBox1.Text)
End Sub
Private Sub ComboBox2_SelectionChangeCommitted _
(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
ComboBox2.SelectionChangeCommitted
MessageBox.Show(Me.ComboBox2.Text)
End Sub
///