This is a migrated thread and some comments may be shown as answers.

Accept Button on ToolWindow

2 Answers 88 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 09 Aug 2011, 08:37 PM

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 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 09 Aug 2011, 08:40 PM
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...
0
Alexander
Telerik team
answered on 11 Aug 2011, 02:56 PM
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 >>

Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or