huang rongchuan

huang rongchuan

  • NA
  • 1
  • 2.5k

Father class how to use the special sub-category type

Aug 31 2008 9:21 PM

Father class how to use the special sub-category type (such as the sub-class form TableAdapter of a table), the current idea is traversal all the things on the form(such as traversing all controls on the sub-form), if found what I need, I want to transform its type into I want. But now what trouble me is i could not get the type neither trying to change the object into the type I needed nor using reflection to get the type. Thanks a lot.
Code is as follows:

private void findcontrol(Control.ControlCollection controls)

{

    foreach (Control ctrl in controls)

    {

        if (ctrl.GetType().Name == "XXTableAdapter")

        {

            //How to use the ctrl as XXTableAdapter to do something

            //just like this: TableAdapter.Update (customers DataTable);

            //the kind of type(XXTableAdapter) just could be founded on sub-class

        }

        findcontrol(ctrl.Controls);

}

}