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

  • Home
  • SEARCH
  • 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 6611359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:57:35+00:00 2026-05-25T19:57:35+00:00

Suppose I don’t want to use if (string.IsNullOrEmpty(textbox1.Text)) { textbox1.Text = null; } for

  • 0

Suppose I don’t want to use

if (string.IsNullOrEmpty(textbox1.Text))
{
     textbox1.Text = null;
}

for every textbox controls in form, is there a easier way to do it ?

  • 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-25T19:57:35+00:00Added an answer on May 25, 2026 at 7:57 pm

    You can iterate through the ControlCollection of the given form, e.g. frmMain.Controls
    Now this will be the basic Control object, so you would need a test to see if it is of type TextBox.

    .NET 2.0 – you’ll have to check this manually
    .NET 3.0+ – use the .OfType<TextBox> extension method to give you only a list of IEnumerable<TextBox>

    Note that iterating through this from the form will only give you text boxes on that form. If you bind text boxes to a container it won’t show up there.

    Safest bet would be to write a recursive function that walks through all the control collections and passes the reference to your test function to perform your test and update.

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

Sidebar

Related Questions

Suppose there are 3 keywords, I don't want to do this kind of replace
I don't suppose there's a way to get at the SPFarm through the OOTB
Suppose I have a large .swf file. Say, it's 10MB. I don't want the
Suppose I have a list (or Set): List<String> testList = Lists.newArrayList(assocX,srcT,destA,srcX, don't care Y,
Suppose we don't know how many slashes we could get in a string but
I don't know if what I want is possible, but is this: Suppose I
Suppose I don't know names of all the folders in a directory. I want
Suppose I have a class that doesn't support memberwise copying so I don't want
Suppose we are creating a generic control in .NET. E.g. a tree. I don't
I don't suppose anyone knows of a function (PHP, preferably) that can take a

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.