Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6931607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:35:58+00:00 2026-05-27T11:35:58+00:00

I have a tabcontrol with 9 tabitems in it. Each tab has as series

  • 0

I have a tabcontrol with 9 tabitems in it. Each tab has as series of TextBoxes for the user to enter data. At the bottom is a clear button, hooked up to this method:

public void ClearTextBoxes()
    {
        ChildControls ccChildren = new ChildControls();

        foreach (object o in ccChildren.GetChildren(rvraDockPanel, 2))
        {
            if (o.GetType() == typeof(WatermarkTextBox) || o.GetType() == typeof(DateBox) ||
                o.GetType() == typeof(DigitBox) || o.GetType() == typeof(PhoneBox))
            {
                WatermarkTextBox water = (WatermarkTextBox)o;
                water.Text = "";
            }
            else if (o.GetType() == typeof(ComboBox))
            {
                ComboBox combo = (ComboBox)o;
                combo.SelectedIndex = -1;
            }
            else if (o.GetType() == typeof(CheckBox))
            {
                CheckBox check = (CheckBox)o;
                check.IsChecked = false;
            }
        }
    }

This works perfectly fine, however I also have a MenuItem that allows the user to ClearAll tabs. Right now the clear button only clears what’s on the currently selected tab, and leaves everything else alone. My thought on how to do this was to iterate through the tabitems with this loop:

        for (int i = 0; i < 10; i++ )
        {
            tabSelection.SelectedIndex = i;
            clearButton_Click(null, null);
        }

It will flip through all the tabs, but won’t clear anything. I have tried using Automation instead, with the same result. It just won’t seem to clear anything.

ChildControls class:

class ChildControls
{
private List<object> listChildren;

public List<object> GetChildren(Visual p_vParent, int p_nLevel)
{
    if (p_vParent == null)
    {
        throw new ArgumentNullException("Element {0} is null!", p_vParent.ToString());
    }

    this.listChildren = new List<object>();

    this.GetChildControls(p_vParent, p_nLevel);

    return this.listChildren;

}

private void GetChildControls(Visual p_vParent, int p_nLevel)
{
    int nChildCount = VisualTreeHelper.GetChildrenCount(p_vParent);

    for (int i = 0; i <= nChildCount - 1; i++)
    {
        Visual v = (Visual)VisualTreeHelper.GetChild(p_vParent, i);

        listChildren.Add((object)v);

        if (VisualTreeHelper.GetChildrenCount(v) > 0)
        {
            GetChildControls(v, p_nLevel + 1);
        }
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:35:59+00:00Added an answer on May 27, 2026 at 11:35 am

    To get your code working you need to add the following line to your cleanup method:

            tabControl.SelectedIndex = i;
    -->        UpdateLayout();
            Button_Click(null, null);
    

    The UpdateLayout method takes care that the TabItem is drawn and the VisualTree is available afterwards.

    Generally this approach isn’t nice and if you have a real Application with Business data behind I’d recommend you have a look at databinding/MVVM. The approach shouldn’t be to reset your controls in the view, but to reset your bound business data in the background.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to create types of Tabitems to my tabcontrol. each tab will have
I have close button in the header of each tab of TabControl. Tabs are
I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with
I have several Telerik RadGridViews within a TabControl. Each of these RadGridViews has a
I have a TabControl with multiple TabItems. In each TabItem there needs to be
I have a TabControl and each Tab can contain the same UI but with
I have a WPF TabControl that has a couple of buttons in the TabItem
I am trying to assign each button on the left its own Tab control.
I have a TabControl bound to a collection and a DataTemplate for the TabItems.
I have an entity class. This entity has lots of properties and entity's data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.