Results 1 to 2 of 2

Thread: Bug with the Default property

  1. #1

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Bug with the Default property

    Follow these steps:

    • Add a Frame to your form, set its enabled property to false.
    • Add a button into the frame, set its default property to true.
    • Add this code in the form's code:
      VB Code:
      1. Option Explicit
      2.  
      3. Private Sub Command1_Click()
      4.     MsgBox "1"
      5. End Sub
    • Run it.


    If you try to click on the button, nothing happens because the frame is disabled. But, the button is set to be the default one, so... hit Enter. Should that MsgBox appear??
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    I wouldn't consider that as a bug but this behaviour's been known for ages and not even form's KeyPreview can handle that. Best way is to subclass window's message when Enter key is pressed or reset Default property when parent container's Enabled is toggled:

    Command1.Default = Frame1.Enabled

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