Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. empty textBoxes

empty textBoxes

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xrado
    wrote on last edited by
    #1

    lets say i have tabpages with lots of textboxes on each page. (winform) is there a shoort way to empty all textboxes on each page?

    T 1 Reply Last reply
    0
    • X xrado

      lets say i have tabpages with lots of textboxes on each page. (winform) is there a shoort way to empty all textboxes on each page?

      T Offline
      T Offline
      techieboi
      wrote on last edited by
      #2

      I use code like the following to set control's to their default values. You can either pass in the tab page to the function or modify it slightly and pass in the tab control and step through the control's pages. private void ClearTextBoxes (Control parentControl) { // Step through each control in the parent control and clear it's text if a textbox foreach (Control control in parentControl.Controls) { if (control is System.Windows.Forms.TextBox) control.Text = string.Empty; } } This method has the added advantage that you can also default check boxes' and other controls' properties by adding an additional if (control is [control type]) statement in the for loop. Hope this helps Aaron

      X 1 Reply Last reply
      0
      • T techieboi

        I use code like the following to set control's to their default values. You can either pass in the tab page to the function or modify it slightly and pass in the tab control and step through the control's pages. private void ClearTextBoxes (Control parentControl) { // Step through each control in the parent control and clear it's text if a textbox foreach (Control control in parentControl.Controls) { if (control is System.Windows.Forms.TextBox) control.Text = string.Empty; } } This method has the added advantage that you can also default check boxes' and other controls' properties by adding an additional if (control is [control type]) statement in the for loop. Hope this helps Aaron

        X Offline
        X Offline
        xrado
        wrote on last edited by
        #3

        thx a lot!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups