프로그래밍 방식으로 폼에 새로운 UserControls 양을 추가하려고합니다. 하나는 항목이 UserControl 내에 포함 된 ComboBox에서 선택 될 때마다 추가됩니다.VB.NET : SelectedIndexChanged multiple 번팅
문제는 SelectedIndexChanged 이벤트가 완전히 이상하게 발생한다는 것입니다. 때로는 두 번, 때로는 세 번 등도 있지만 한 번만은 아닙니다. 콤보 상자의 SelectedIndex를 -1로 설정 한 횟수에 상관없이 적어도 한 번은 SelectedIndex가 0으로 시작됩니다. 때때로 Itemselected 이벤트가 SelectedIndexChanged 이벤트 사이에서 여러 번 발생합니다.
InvoiceEntry.vb는 니펫을 :
Public Event ItemSelected As EventHandler
Private Sub cboItem_SelectedIndexChanged(sender As System.Object, _
e As System.EventArgs) Handles cboItem.SelectedIndexChanged
RaiseEvent ItemSelected(Me, EventArgs.Empty)
End Sub
Invoice.vb 조각 :
Private numEntries As Integer = 1
Public Sub invEntry1_ItemSelected() Handles invEntry1.ItemSelected
numEntries += 1
Dim newEntry As InvoiceEntry = invEntry1
Dim pt As Point = newEntry.Location
pt.Y += 30
newEntry.Location = pt
newEntry.Name = "invEntry" + numEntries.ToString
pnlEntries.Controls.Add(newEntry)
최종 하위 내가 잘못되고있는 것이 무엇인지에 대한 완전한 손실에있어
. 나 또는 다른 누군가가 알아낼 때까지이 글을 모니터링 할 것이므로 더 많은 정보가 필요하면 알려 주시기 바랍니다.
사용해보십시오 콤보 상자에서 무언가를 선택했습니다! 이 문제는 과거에도 여러 번 저를 괴롭혔고 적절한 솔루션을 찾을 수 없었습니다. 너는 영웅이다. –