I've built a on-screen keyboard for a surveillance system made in VBA. I need it so that when the user clicks on the textbox to enter the data, the on-screen keyboard I've made, shows up. Thanks!
Check out the _Enter() event that fires when a user clicks inside the textbox control.
Private Sub TextBox1_Enter()
frmKeyboard.Show
End Sub
For a more complete solution, you may want to wrap the keyboard showing/hiding events in a VBA class so you can more easily apply it to the different text boxes on your form. That way you don't have to repeat all of your code for each text box on your form. Just something to explore for down the road. :-)
Related
Using VB.net for a windows form application. I'm tired of always having to backspace the default '0' of a numeric updown control. What I would like to do is have the value selected automatically on enter, so that I can just type over it.
I've tried this:
Private Sub updown1_Enter(sender As Object, e As EventArgs) Handles updown1.Enter
Me.updown1.Select(0, updown1.Text.Length)
End Sub
I've used a break point to verify that it does indeed run, but it doesn't seem to do anything. What am I missing?
Your code is actually selecting the value as intended, it is just being undone by a mouse event almost instantaneously. When you click to enter a NumericUpDown, the events fire in the following order:
Enter
GotFocus
MouseDown
Click
MouseUp
As you probably know, in controls with text fields the native behavior places the cursor wherever you've clicked inside the textbox. This is what's causing your problem. You have selected the text at Enter, but then a bunch of mouse events come along and undo all your hard work. The obvious solution is to just use the MouseUp event since that's at the end of the list, but MouseUp will fire for anywhere you click inside the control so you'll have to decide if that behavior is acceptable for you.
I am using Access Database to make a program.
Here is the problem:
After I enter the data in textbox, which is in a blue boxes, and click 'Add Data' button, data move to the ListBox, which is marked with orange box. But I should press 'F5' button(refresh) to see the data. I want to see the data immediately after I click 'Add Data' button. Is there any way to do that?
Any comments would be greatly thankful(It would be nice if you can share your code)
Add ListBox.Requery to the button's click event right after new data has been added to the ListBox.
Private Sub YourButtonName_Click()
'Add data
Me.YourListBoxControlName.Requery
End Sub
requerying the form is the simplest way probably, but with no idea of what the button does, how your data is structured, how the form is structured, i.e. is the listbox bound or unbound, so cant really say, if F5, is doing it, then just look for the VBA method for refreshing the form.
I have a few different userforms in Excel 2007 right now and was wondering if I could add a "?" button next to the close symbol in the userform.
Alternatively, is there a way to display some text when I hover over a specific label
The form property "WhatsThisButton" displays the question mark icon next to the close button, but this does nothing without creating an actual help file and assigning it to your form, this is not an easy thing to do. Far easier is to display text as you have described, each control has a "controlTipText" property that will display whatever text you enter in there, when your user hovers their mouse over the control
I'm building on top of code that a previous developer has left me, and he left something that intrigued me quite a bit.
Basically on his menus, he has a TextBox to take in user input and a button next to it to submit the value of the TextBox (for example if the user wanted to select option 1, he would input 1 into the TextBox and click the button). However, the user could also press the Enter key while focusing the TextBox, and it would be treated as the submit button was clicked.
Now this is simple enough to do, but when I check the VB code behind the menu, there's no TextBox_Keydown(...) Handles TextBox.Keydown function anywhere, only the button click event. How is he doing this? He has several menus that are similar and I can't figure out how.
A standard dialog box, if not told to act otherwise, enter does default command button and escape does cancel. In VB look at the properties Default for the command button.
I discovered how he was doing it. He basically mapped the AcceptButton and CancelButton properties of the entire Windows Form to various button functions.
I want to find a way to make a specific button, the form's default button,
I.e. the button that is highlighted when the form opens for the first time.
I tried the AcceptButton property but when I run the program, that does not work.
Any idea?
Thank you in advance,
Tassos
You need to change the AcceptButton property of the containing form.
form1.AcceptButton = button1
Here form1 is the Form whose default button you need to set, and button1 is the name of the Button on that form.
The form's AcceptButton and CancelButton properties define the default behaviour for the Enter and Escape keys, rather than the highlighting.
To highlight the button use the Focus method, but when doing this in the form_load event you will need to call the Select method instead.
btnDefault.Select()
As mentioned in the comments, setting the control to the lowest taborder will achieve the same thing
The answer from 'chk' on 5/2/13 is the correct answer, but is shown as a string which of course is not the way to do it.
Also, in the form's property sheet you can find, under Misc, the property 'AcceptButton'. This will give you a list of buttons on the form - just select the one you want.
The button selected as the AcceptButton will behave as the 'default' button. It will be 'highlighted' with a darker border and will be clicked when you push the Enter key on your keyboard.
Setting up an AcceptButton is different than setting the button's focus. The AcceptButton's click event will be triggered by the Enter key no matter which control has the focus on the form.
You can also do this programmatically.
I have a maintenance form where initially I want the "search" button as the form accept button.
when I'm displaying the field maintenance area, I want the "ok" button to be the accept button.
You simply change this in the appropriate areas in your code to Me.AcceptButton = MyButtonName.