I have a VB.NET application and it is for data entry. There are several ComboBox components and only recently I changed going backwards trough the form with Left arrow to PageUp, since pressing Left/Right arrows decreases/increases value in the ComboBox.
I have this new code with PageUp for my components:
Though it seems promising, PageUp changes the value in a ComboBox once you have selected with mouse different value then it was.Code:Private Sub cboPol_GotFocus(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cboPol.GotFocus cboPol.SelectAll() End Sub Private Sub cboPol_KeyDown(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyEventArgs) Handles cboPol.KeyDown Dim KeyCode As Short = eventArgs.KeyCode Dim Shift As Short = eventArgs.KeyData \ &H10000 If KeyCode = Keys.PageUp Then meEmb.Focus() End If End Sub Private Sub cboPol_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles cboPol.KeyPress Dim KeyAscii As Short = Asc(eventArgs.KeyChar) If KeyAscii = Keys.Enter Or KeyAscii = Keys.PageDown Then If cboPol.Text = "" Then obrazecZaVnesRef.proverkaCelObrazec = True cboPol.Focus() MsgBox(SV20_MessagesModule.VNESETE_POL_MSG, MsgBoxStyle.Information) Else obrazecZaVnesRef.pol = vbNetUtilsDZS.convertToPositiveInteger(cboPol.SelectedItem) meRNasmes.Focus() End If End If eventArgs.KeyChar = Chr(KeyAscii) If KeyAscii = 0 Then eventArgs.Handled = True End If End Sub Private Sub cboPol_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPol.SelectedIndexChanged obrazecZaVnesRef.pol = vbNetUtilsDZS.convertToPositiveInteger(cboPol.SelectedItem) End Sub
Which keyboard button can be used to jump trough fields of a Form backwards in the field list without affecting the previously selected value in the ComboBox components?
Or somehow I can prevent changing ComboBox components from changing its value when jumping to other field?




Reply With Quote
