Find textbox control

3 posts, 0 answers
  1. TAYIM
    TAYIM avatar
    2 posts
    Member since:
    Mar 2009

    Posted 05 Oct 2011 Link to this post

    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. erwin
    erwin avatar
    337 posts
    Member since:
    Dec 2006

    Posted 06 Oct 2011 Link to this post

    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




  3. Ivan Petrov
    Admin
    Ivan Petrov avatar
    682 posts
    Member since:
    Sep 2012

    Posted 07 Oct 2011 Link to this post

    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 >>

Back to Top