GcMaskedComboBox的SelectedIndex事件的问题
现在的处理里面,含有控件GcMaskedComboBox,但是最近发现这个控件的SelectedIndexChanged的触发有些不正常。代码会在下面进行粘贴。先说下操作动作。
①,画面初期启动,光标在移动到ComboBox里面,输入值 0 ,通过Tab键把光标移开,TextBox的值不会发生变化。
②,按下Tab键,光标移到ComboBox里,点击ComboBox的▼,TextBox的值因为触发SelectedIndexChanged事件,变成了 0
③,按下Tab键,光标移开,再次按下Tab键,光标回到ComboBox里,输入值1,TextBox的值因为触发SelectedIndexChanged事件,变成了 1
④、光标迁入ComboBox,点击▼,DropDown打开,再次点击DorpDown关闭,输入值2 ,TextBox的值因为触发SelectedIndexChanged事件,变成了 2
其他动作不写了。根据上面的一系列的光标移开,点击下拉框(▼),输入值等操作,发现了下面的规律。
Ⅰ,DropDown点开的同时会触发SelectedIndexChanged事件。
Ⅱ,DropDown点开关闭后,第一次输入肯定会触发SelectedIndexChanged事件。
单一关于上面的动作,InputMan4.0是不会触发上面的动作的,所以希望把上面的两个动作(Ⅰ、Ⅱ)都不触发。有没有什么好办法???
Public Class InputMan
Friend WithEvents cmbEXPENSE_DIV As New GrapeCity.Win.Editors.GcMaskedComboBox
Dim txt As New TextBox
Private Sub InputMan_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim MaskPatternField1 As GrapeCity.Win.Editors.Fields.MaskPatternField = New GrapeCity.Win.Editors.Fields.MaskPatternField()
Me.cmbEXPENSE_DIV.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.cmbEXPENSE_DIV.DropDown.AllowResize = False
Me.cmbEXPENSE_DIV.DropDown.Width = 67
MaskPatternField1.MaxLength = 1
MaskPatternField1.Pattern = "\D"
Me.cmbEXPENSE_DIV.Fields.AddRange(New GrapeCity.Win.Editors.Fields.MaskField() {MaskPatternField1})
Me.cmbEXPENSE_DIV.FlatStyle = GrapeCity.Win.Editors.FlatStyleEx.Flat
Me.cmbEXPENSE_DIV.Font = New System.Drawing.Font("MS ゴシック", 12.0!)
Me.cmbEXPENSE_DIV.HighlightText = GrapeCity.Win.Editors.HighlightText.All
Me.cmbEXPENSE_DIV.ImeMode = System.Windows.Forms.ImeMode.Disable
Me.cmbEXPENSE_DIV.ListHeaderPane.Height = 23
Me.cmbEXPENSE_DIV.ListHeaderPane.Visible = False
Me.cmbEXPENSE_DIV.Location = New System.Drawing.Point(7, 19)
Me.cmbEXPENSE_DIV.Margin = New System.Windows.Forms.Padding(4)
Me.cmbEXPENSE_DIV.Name = "cmbEXPENSE_DIV"
Me.cmbEXPENSE_DIV.PromptChar = Global.Microsoft.VisualBasic.ChrW(32)
Me.cmbEXPENSE_DIV.Size = New System.Drawing.Size(67, 22)
Me.cmbEXPENSE_DIV.TabIndex = 1
Me.Controls.Add(cmbEXPENSE_DIV)
With cmbEXPENSE_DIV
.Items.Clear()
.Items.Add("0")
.Items.Add("1")
.Items.Add("2")
.Items.Add("3")
End With
txt.Size = New System.Drawing.Size(67, 22)
txt.Location = New System.Drawing.Point(90, 19)
txt.TabIndex = 0
Me.Controls.Add(txt)
End Sub
Private Sub cmbEXPENSE_DIV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbEXPENSE_DIV.SelectedIndexChanged
txt.Text = cmbEXPENSE_DIV.Text
End Sub
End Class 回复 1楼sxyweiren的帖子
哎呀,这第二条怎么着看着都像是个Bug
想了半个上午了。有这么一段代码你拿去试试看。
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.GcMaskedComboBox1.Items.Add("0")
Me.GcMaskedComboBox1.Items.Add("1")
Me.GcMaskedComboBox1.Items.Add("2")
Me.GcMaskedComboBox1.Items.Add("3")
Dim dropDownButton = DirectCast(Me.GcMaskedComboBox1.SideButtons(0), GrapeCity.Win.Editors.DropDownButton)
dropDownButton.IsDefaultBehavior = False
AddHandler dropDownButton.Click, AddressOf Me.OnDropDownButtonClick
End Sub
Private ignoreNextSelectedIndexChanged As Boolean
Private Sub OnDropDownButtonClick(sender As Object, e As EventArgs)
ignoreNextSelectedIndexChanged = True
Me.GcMaskedComboBox1.SwitchDropDown()
ignoreNextSelectedIndexChanged = False
End Sub
Private Sub OnSelectedIndexChanged(sender As Object, e As EventArgs) Handles GcMaskedComboBox1.SelectedIndexChanged
If ignoreNextSelectedIndexChanged Then
Return
End If
System.Diagnostics.Debug.WriteLine(String.Format("[{0}]SelectedIndexChanged!", DateTime.Now.TimeOfDay))
End Sub
Private Sub OnComboBoxKeyPress(sender As Object, e As KeyPressEventArgs) Handles GcMaskedComboBox1.KeyPress
ignoreNextSelectedIndexChanged = True
End Sub
Private Sub OnComboBoxKeyUp(sender As Object, e As KeyEventArgs) Handles GcMaskedComboBox1.KeyUp
ignoreNextSelectedIndexChanged = False
End Sub
End Class
页:
[1]