locked
Recognizing UI element RRS feed

  • Question

  • Hi!

    I have a control that contains few other controls (different types)

    <MainCOntainer>
    <Button />
    <Button />
    <CheckBox />
    <Button/>
    </MainCOntainer>


     

    In my code behind I'm going through all Children of MainContainer. I want the code to take some action when it finds checkbox. How to achive this?

    thanks

    pete

     

    Wednesday, November 17, 2010 11:33 AM

Answers

  • You can compare against its type.

    if (control is Checkbox)
    {
       Checkbox cb = (Checkbox)control;
    }
    else if (control is TextBox)
    {
       TextBox txt = (TextBox)control;
    }


     

    Wednesday, November 17, 2010 11:38 AM

All replies

  • You can compare against its type.

    if (control is Checkbox)
    {
       Checkbox cb = (Checkbox)control;
    }
    else if (control is TextBox)
    {
       TextBox txt = (TextBox)control;
    }


     

    Wednesday, November 17, 2010 11:38 AM
  • Worked perfectly! thanks

    Wednesday, November 17, 2010 11:41 AM