Results 1 to 4 of 4

Thread: an easy question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    17

    Post

    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

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    17

    Post

    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.

  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width