how to get all controls in foreach loop in c#
  • Hello
    I want to know that how can i get all controls in a for-each loop in c# in windows fom app. I want to clear all text boxes when an operation is successful. i know ho to clear all values one by one but i want to clear all text boxes using a for-each loop.
  • 1 Comment sorted by
  • Vote Up1Vote Down WaqasWaqas
    172.00 Karma Accepted Answer
    hi sajid you can use this

    foreach (var Control in this.Controls)
    if (Control is TextBox)
    ((TextBox)Control).Text = "";

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative