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

Find textbox control

2 Answers 325 Views
PageView
This is a migrated thread and some comments may be shown as answers.
TAYIM
Top achievements
Rank 1
TAYIM asked on 05 Oct 2011, 06:06 PM
Hi to everyone
this is my problem
on a radform, I placed a radpageview control with 02 pages
inside this pages, I placed texboxes, group etc..
I also have a button somewhere inside the radform
How can I reset all the textboxes (xtextbox.text="") ?
My english is not so good
thanks

2 Answers, 1 is accepted

Sort by
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 06 Oct 2011, 05:51 PM
Hey Tayim,

several possibilities come to mind:

1) in the designer, select the control and clear it's Text Property. That should also work with multiple controls selected. You might need to select the different pages individually - that gives some more clicks.

2) open the designer codebehind file and work out a clever regular expression to replace .Text=".*" with .Text=""

3) in code: recursively iterate over the forms controls collection and reset the .Text properties of the controls you are interested in. When you get a RadPageView control you may need some more specific code to get to the different pages and their controls.

I'm sure other people will come up with even more ways.

regards
Erwin
0
Ivan Petrov
Telerik team
answered on 07 Oct 2011, 05:08 PM
Hi TAYIM,

Thank you for writing.

As Erwin has posted, it depends on when you want to "reset" the text. If you are doing it in the designer, you can use the Visual Studio property grid and set the Text property of each RadTextBox. Or you can use the Find & Replace dialog of Visual Studio to replace the text with an empty string in the form .Designer.cs file. If you want to do it at runtime, you can iterate through the controls on each page of the RadPageView, check if the control is RadTextBox and then reset the text. Here is a code snippet which demonstrates this:

foreach (RadPageViewPage page in this.radPageView1.Pages)
{
  foreach (Control control in page.Controls)
  {
    if (control is RadTextBox)
    {
      ((RadTextBox)control).Text = String.Empty;
    }
  }
}

I hope this will help you. If you have further questions, do not hesitate to ask.

Kind regards,
Ivan Petrov
the Telerik team

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

Tags
PageView
Asked by
TAYIM
Top achievements
Rank 1
Answers by
erwin
Top achievements
Rank 1
Veteran
Iron
Ivan Petrov
Telerik team
Share this question
or