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

How to select a textbox inside a page?

3 Answers 81 Views
PageView
This is a migrated thread and some comments may be shown as answers.
George Saveliev
Top achievements
Rank 1
George Saveliev asked on 08 Feb 2011, 12:42 PM

Hello!

If I create a simple RadForm with a single RadTextBox, this text box is selected (gets input focus and shows cursor) automatically when the form is shown. If I create a simple RadForm with a RadPageView and place the RadTextBox into the page, it is not selected automatically when the form is shown.

Even the following code does not select the text box:

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
 
    radTextBox1.Focus();
    radTextBox1.Select(0, 0);
}

The following workaround does work, but I do not think this is a way I should go:

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
 
    Application.Idle += Application_Idle;
}
 
void Application_Idle(object sender, EventArgs e)
{
    Application.Idle -= Application_Idle;
    radTextBox1.Focus();
    radTextBox1.Select(0, 0);
}

So, how should I correctly select the text box in the PageView page when the form is shown?

Thank you.

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Feb 2011, 12:58 PM
Hello,

It should be fine if you move the code
radTextBox1.Focus(); 
radTextBox1.Select(0, 0); 
to the FormShown event, not the FormLoad event.

Hope that helps
Richard
0
George Saveliev
Top achievements
Rank 1
answered on 08 Feb 2011, 01:15 PM

Thank you!

0
Richard Slade
Top achievements
Rank 2
answered on 08 Feb 2011, 01:17 PM
Glad I could be of help, George.
Richard
Tags
PageView
Asked by
George Saveliev
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
George Saveliev
Top achievements
Rank 1
Share this question
or