Results 1 to 9 of 9

Thread: Disabling Button Focus

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2013
    Posts
    50

    Disabling Button Focus

    So, I'm running into an issue, which I believe has to do with button focus.

    Lets say you have a search bar in your program where the user could search for files.
    You set AcceptButton to the associated button for enabling the search field.

    In my program, once the enter button is pressed and the search is performed, that search button remains highlighted.

    I have several search fields like this, all of which I've set the AcceptButton on - for ease of use.

    Honestly, I just think its visually annoying to have these random buttons highlighted after being pressed.

    I've tried setting the focus to other objects (adding that code below the various search button codes).
    Unfortunately, that didnt work as I had hoped - it disabled the user for being able to type anything into the search fields.

    Any help would be greatly appreciated.
    Thank you for your time!

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: Disabling Button Focus

    Have you tried setting focus to another control via ActiveControl = SomeControl ?

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2013
    Posts
    50

    Re: Disabling Button Focus

    Kevin - I appreciate your input - unfortunately, that didnt work.

    Ideally, once a search button is pressed, I'd like to focus on the window that displays all of the search results.
    I've tried:

    Code:
    ActiveControl = SearchWindow
    So will this only work if I select another control for the focus - ie, one of the other buttons?

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: Disabling Button Focus

    Guess I misunderstood you, I was thinking you wanted to set focus to a control and not a window.

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Disabling Button Focus

    Quote Originally Posted by kevininstructor View Post
    Guess I misunderstood you, I was thinking you wanted to set focus to a control and not a window.
    Are these 'windows' forms? If so just bring the search form to the front and select the appropriate control.
    Last edited by dbasnett; Jan 26th, 2013 at 10:47 AM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Disabling Button Focus

    Well if you are using default controls and no custom code for highlighting then it should be as simple as

    Control.Focus

    That said you have not given us much to go on, we don;t even know what kind of app you are talking about here

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Disabling Button Focus

    There is a note here http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx that says, "Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms."
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Disabling Button Focus

    hmm I had not saw that, I do mostly mobile apps in Vb.Net and have been using the .Focus method for years under VB 2003, 2005 and 2008 never had any issues with it.

  9. #9
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Disabling Button Focus

    Quote Originally Posted by DataMiser View Post
    hmm I had not saw that, I do mostly mobile apps in Vb.Net and have been using the .Focus method for years under VB 2003, 2005 and 2008 never had any issues with it.
    Maybe a CYMSA.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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