Accept Button on ToolWindow

3 posts, 0 answers
  1. Adam
    Adam avatar
    12 posts
    Member since:
    Apr 2011

    Posted 09 Aug 2011 Link to this post

    I have a rather complex application that has many UI components. I'm attempting to use the radDock and create a ToolWindow that has search capabilities. This ToolWindow has a RadPanel on it with RadTextBoxes for the different fields they can search. It also has a RadButton to perform the search. What I'd like to do is have it so when the user clicks in the panel or clicks in the textbox, that the AcceptButton for the form becomes the search button...

    example:

    private void customerSearchNumberTextBox_GotFocus(object sender, EventArgs e)
    {
        this.AcceptButton = customerSearchButton;
    }
     
    private void customerSearchButton_Click(object sender, EventArgs e)
    {
        int i = 1;
    }

    However, this isn't working...the GotFocus event fires, and the above code is executed, but when I hit 'enter' nothing happens....the click event doesn't fire...thoughts?

  2. Adam
    Adam avatar
    12 posts
    Member since:
    Apr 2011

    Posted 09 Aug 2011 Link to this post

    Ultimate goal here is to have AcceptButton be different based on what they are currently doing in the UI. A work around (which I'd rather not code up if there is another solution) would be to check the OnKeyPress event...if it's enter, then manually execute the search. Seems clunky and hackish given that AcceptButton was written to do this...
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 11 Aug 2011 Link to this post

    Hello Adam,

    Thank you for your question.

    I suppose you use auto-hidden ToolWindow in your scenario. This window is hosted in its own form (toolWindow1.FloatingParent) and this is the form which receives the pressed Enter key. This is why it never reaches your main form. Even checking the OnKeyPress event in your main form will not allow you to handle the pressed key.

    You can achieve your scenario handling KeyPress events to the individual controls in the ToolWindow.

    I hope it helps.

    Best regards,
    Alexander
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top