#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12

    Accept Buttons in Vb.Net for a GroupBox ?


    is it possible to create or make a way to have a Accept Buttons in a GroupBox ?

    There is a property for a Frame where you can set a button to be the default Accept Buttons, that's mean each time you press enter in the frame it will go to this button.

    My problems is that the Enter need to work only for a certain groupbox and not the entire frame. I have a groupbox where the objects in it are generated custom and change often, but I need to be able to press enter and go directly to this button.

    I would like to know if there is a way to make that easily ?
    There isn't a KeyDown property for the groupbox either.

    Does I need to add a property or new code to a new class of objets that would be added to the groupbox ? then my problem will be to make two communicate with each others.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Bavaria, Germany
    Posts
    140
    Rep Power
    12
    That's a HTML limitation, one form can only contain one default (the first if not otherwise specified) submit button.

    But you can cheat with javascript :-)

    The attached file contains a html file with 3 fieldsets (groups) with 1 textbox and 3 buttons (Buttons 1 - 3). If the first textbox has the focus and you press enter, button1 will be clicked, in the second button two and in the third button third.

    This example handles the keydown inside the fieldset tag.
    Code:
    <fieldset id="Group<x>" onKeyDown="fnKeyDown(this)">
      ...
    </fieldset>
    Every time you press a key while a fieldset (or a child node of it) has the focus the javascript function "fnKeyDown" will be called.

    Because the function is called on *every* click and we just want to handle "enter" we quit if your keyCode is not 13 (== linefeed).
    Code:
    if (event.keyCode != 13)
      return;
    Inside this function we check who clicked us and then call the button depending which group has the focus.
    Code:
    if (group.id == "Group1") {
      document.getElementById("Group1Button1").click();
    } else if (group.id == "Group2") {
      document.getElementById("Group2Button2").click();
    } else if (group.id == "Group3") {
      document.getElementById("Group3Button3").click();
    }
    Hope this helps you...
    Attached Files
    Last edited by Wingman; September 16th, 2003 at 12:43 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    ok, thank you for your answer. Doesn't help me but it's tell me what I tought before !

    I just can't do it like that !

IMN logo majestic logo threadwatch logo seochat tools logo