Results 1 to 15 of 15

Thread: What gets selected, when the project is run?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    234

    What gets selected, when the project is run?

    For example, I had a button, but I disabled it in FormLoad. Now a radio button gets activated for no apparant reason...How do I control what gets focus and what doesent?

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: What gets selected, when the project is run?

    use the .SetFocus

    like text1.setfocus

    its done by the tab order
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Member
    Join Date
    May 2007
    Posts
    60

    Re: What gets selected, when the project is run?

    but do it in the Activate Event rather than the Load.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    234

    Re: What gets selected, when the project is run?

    what if there are no members that I like that have that property, how do I stop anything from being activated?


    -----Leave Activate empty
    wait...no, thats not completely right... can someone clear this up for me? how does VB single out the one button I DO NOT want clicked, and clicks it at load?
    Last edited by unxzst; Nov 5th, 2007 at 04:17 PM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    234

    Re: What gets selected, when the project is run?

    Whats going on? I cant even debug this, because when I do - everything works smooth, but if I press run it goes straight for OptionButton_Click(Index As Integer) with a preset index out of nowhere...

  6. #6
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: What gets selected, when the project is run?

    If you don't want to see anything gets focus when the form loads, create a Dummy text box, that has :
    tab_index=0, enabled=true, locked=true,
    width=0, left=0, border=transparent (or put it outside of viewable area.)

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: What gets selected, when the project is run?

    Quote Originally Posted by unxzst
    How do I control what gets focus and what doesent
    TabIndex=0. Whichever control has that property set will be the first to get focus, assuming it is enabled and can get the focus. Otherwise then next control in the tab order will get the focus if it can... Controls that can't receive focus are those that are invisible, those without an hWnd property (i.e., label, image control) and those that are disabled or are in a disabled container.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: What gets selected, when the project is run?

    Put all your controls on that form in a frame. Set it to borderless and no caption. Then disable the frame and all controls in it will be disabled but look normal.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: What gets selected, when the project is run?

    Quote Originally Posted by RobDog888
    Put all your controls on that form in a frame. Set it to borderless and no caption. Then disable the frame and all controls in it will be disabled but look normal.
    Or simply put

    Option1.Value = False
    Option2.Value = False

    etc in the form's Activate event.

  10. #10
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: What gets selected, when the project is run?

    @RodDog, your way will make it "look normal" but all controls are disabled, you will need code to enable them.
    I think the OP wants no control gets focus when open the form but they must be enabled as normal and ready to be clicked.
    By default, as LaVolpe said, the first enabled control (in tab order), if any, will receive focus when the form open, if no enabled control the form will receive focus.

  11. #11
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: What gets selected, when the project is run?

    Quote Originally Posted by anhn
    @RodDog, your way will make it "look normal" but all controls are disabled, you will need code to enable them.
    I think the OP wants no control gets focus when open the form but they must be enabled as normal and ready to be clicked.
    By default, as LaVolpe said, the first enabled control (in tab order), if any, will receive focus when the form open, if no enabled control the form will receive focus.
    That code would just be

    Frame1.Enabled = True

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: What gets selected, when the project is run?

    I think if the OP tells us what controls are on the form and what is to be non-selected at form load/activate then it may be easier to suggest. If all controls will need to be deselected or just a few then its easy to just set them all to False or whatever for each control in the activate event. We dont know what the OP is ultimately trying to achieve.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: What gets selected, when the project is run?

    @MartinLiss,
    Yes, I know it just be "Frame1.Enabled = True" but where to put it and when it will be run. After enable Frame1, the problem will come back.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: What gets selected, when the project is run?

    It could easily be placed in a button click event if the button is not in the frame but we have no idea what the OP wants / needs so its all unsolveable for now.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: What gets selected, when the project is run?

    Quote Originally Posted by anhn
    @MartinLiss,
    Yes, I know it just be "Frame1.Enabled = True" but where to put it and when it will be run. After enable Frame1, the problem will come back.
    Try it and you'll see that when you enable the frame the option buttons value(s) will not be set to True.

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