|
-
Dec 19th, 2019, 07:16 AM
#1
Thread Starter
Addicted Member
Combobox stays in blue once the focus is moved to other field?
Not sure what is the problem here, I have few combo boxes which
drop down style is DropDown,
AutoCompleteMode is SuggestAppend
AutoCompleteSource is ListItems
Though I explicitly move the focus to other field, the ComboBox text is still in blue background and white text.
What is happening here?
Sample code:
Code:
Private Sub cboPrograma_KeyDown(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyEventArgs) Handles cboPrograma.KeyDown
Dim KeyCode As Short = eventArgs.KeyCode
Dim Shift As Short = eventArgs.KeyData \ &H10000
If KeyCode = Keys.Left Then
meOtsek.Focus()
End If
End Sub
Private Sub cboPrograma_GotFocus(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cboPrograma.GotFocus
cboPrograma.SelectAll()
End Sub
Private Sub cboPrograma_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboPrograma.KeyUp
If e.KeyCode = Keys.Left Or e.KeyCode = Keys.Right Then
e.Handled = False
ElseIf Convert.ToInt32(cboPrograma.Text) > 0 or Convert.ToInt32(cboPrograma.Text) < 4 Then
meDen.Focus()
End If
End Sub
Private Sub cboPrograma_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPrograma.SelectedIndexChanged
obrazecZaVnesRef.programa = vbNetUtilsDZS.convertToPositiveInteger(cboPrograma.Text)
End Sub
-
Dec 19th, 2019, 07:22 AM
#2
Re: Combobox stays in blue once the focus is moved to other field?
I'm not sure whether it's related but you almost certainly shouldn't be calling Focus or handling GotFocus. If you read the relevant documentation you'll see that an application developer should generally be calling Select and handling Enter.
-
Dec 19th, 2019, 08:07 AM
#3
Thread Starter
Addicted Member
Re: Combobox stays in blue once the focus is moved to other field?
Didn't know that, but thanks for the advice.
I should be using TabIndex and SendKeys to move trough the form?
-
Dec 19th, 2019, 02:11 PM
#4
Re: Combobox stays in blue once the focus is moved to other field?
I've had this problem but it's been so long ago I can't remember the exact situation. It might have been caused by trying to move between controls without using the Tab key, I'm just not sure. Anyway you could always just do this,
Code:
ComboBox1.SelectedText = Nothing
-
Dec 19th, 2019, 08:41 PM
#5
Re: Combobox stays in blue once the focus is moved to other field?
 Originally Posted by kutlesh
Didn't know that, but thanks for the advice.
I should be using TabIndex and SendKeys to move trough the form?
You should set up the Tab order as you want in any form. The user can then navigate by pressing the Tab key. If you want to advance to the next control via code then you call SelectNextControl.
-
Dec 20th, 2019, 02:44 AM
#6
Thread Starter
Addicted Member
Re: Combobox stays in blue once the focus is moved to other field?
By documentation, do you consider MSDN on WinForms? We have a CD of MSDN but I don't have it installed.
Or you have some docs on this site about WinForms mechanism?
Or maybe this https://docs.microsoft.com/en-us/dot...work/winforms/
The application is for data entry. There are 40000 rows to be input. It should be optimized for fast data entry. That is why the day is a masked text box and not a numeric picker, and Tab key is replaced with Enter. Enter key is closer to the numeric keypad.
And yes we are still collecting data using paper sadly...
If the moderator could move this last post I wrote to this topic http://www.vbforums.com/showthread.p...39#post5439939
Last edited by kutlesh; Dec 20th, 2019 at 02:49 AM.
-
Dec 20th, 2019, 03:03 AM
#7
Re: Combobox stays in blue once the focus is moved to other field?
Microsoft Docs has succeeded MSDN as the source for documentation on Microsoft development. As you're using an old version of VS, your MSDN documentation would still be valid, but it's probably easier to use the online Docs site. Whenever I want specifics regarding types or members, I always go straight to the API documentation:
https://docs.microsoft.com/en-au/dot...tframework-4.8
That defaults to .NET Framework 4.8 but you can modify the query string or remove it to default to all APIs.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|