Results 1 to 7 of 7

Thread: setting a focus on a textbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    121

    setting a focus on a textbox

    is there a way to set the focus of a textbox to false after data is inserted into it?

  2. #2
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    You could make it read only, but that won't stop it from getting the focus.

    You could disable it.

    You could set the tabstop to false. A user would have to click it manually to set the focus on it.

    Any of these help?
    That which does not kill us, only makes us stronger.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    121
    the only problem is that my program automatically inserts text, and when it inserts the text it gives the focus to the textbox.

    i'm thinking i could try something like making an invisible checkbox and checking it after the text is entered.

    thanks for the help.

  4. #4
    Lively Member
    Join Date
    Aug 2001
    Posts
    65
    What about putting the the textbox in a frame controle and then disable the frame after you've added the data, would that send the focus to another controle, don't know if that will work though
    Last edited by SAS-Trooper; Jun 1st, 2002 at 08:30 PM.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    121

    problem narrowed down

    well, i think i've narrowed down the problem. i have the code: "If textbox1.focus = false then..." on my group Leave event. so when i compile and click on any control outside my group (when i leave the group) and my code subsequently checks to see if the textbox focus is false, it GIVES the textbox focus.

    the first click on a control outside my group does not activate the control, but gives the textbox focus. i've now left my group and the textbox has focus, but the control hasn't responded (which was the point of clicking on it). only after another click (after i've left the group) will the control respond. if i leave out the code to check if the textbox has focus everything works fine.

    this can't be how it's supposed to work can it?

  6. #6
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    If textbox1.focus = fasle

    textbox1.focus is actually a function call that will give the control the focus. The return value from that call is being evaluated by your if statement.

    Maybe you can set a flag in the controls enter/leave event to determine if it has the focus. I'm not on a computer with .NET, so I can't check to see for sure, but I don't think you could get lucky enough for there to be a HasFocus property.
    That which does not kill us, only makes us stronger.

  7. #7
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    Try the ContainsFocus or Focused property. ContainsFocus will look at child controls as well as the parent. Hope this helps.
    That which does not kill us, only makes us stronger.

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