Click to See Complete Forum and Search --> : an easy question
matcathy
Jan 26th, 2000, 12:40 PM
we can always use short-cut key to act like using a mouse to click on a button or fire a command.
for example: using ALT+F will fire the File menu on the tool bar.
in VB, there is an event call 'Click'. in this case, we know the user click on something.
my question is how can you tell if the user is using the short-cut key.
thanks
chrisjk
Jan 26th, 2000, 01:47 PM
It doesn't make any difference, the Click event is still fired despite the user not using the mouse to click. For example, and OnClick event for a button will fire no matter what method they use to "press" it (Enter key, shortcut key, mouse etc)
Regards,
------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)
matcathy
Jan 26th, 2000, 02:14 PM
I use the TrueDBGrid in my application. User can add new record to db directly using it. If user enter a new row then clicks on the 'Insert' button, the record will insert to db. Same as if user move down or up one row, record will be inserted.
But, however, I set up the shortcut key ALT+I for 'Insert'. When user type in the record and stay in the same row without going up/down to other rows or clicks on the 'Insert' button and just ALT+I it. Record will not be saved in the db.
That is the reason why I need to know how to detect if user is using the shortcut key.
I hope I explain more clearly now.
thanks.
Buzby
Jan 27th, 2000, 11:58 AM
This is because the AddNew row of the TrueDBGrid is still holding the unsaved data.
Method 1:
At the beginning of your insert function (ie, the button with the shortcut of ALT+I) do a TDBGrid1.Update - this will update the unsaved record on the grid to the database .. I think.. you may need to check this in the help.
Method 2:
Change the grid to AllowAddNew=False - that way users can only add to the grid when they click on your button or press the shortcut key.
------------------
Mark "Buzby" Beeton
VB Developer
BuzbyB@HotMail.Com
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.