Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Enumerating controls
Message
De
20/02/2009 09:02:16
John Baird
Coatesville, Pennsylvanie, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01382619
Message ID:
01383060
Vues:
45
>Hi John, I have it sorted now - this is the updated code
>
>
>public virtual void ClearData()
>        {
>            foreach (Control c in this.Controls)
>                if (c.Controls.Count > 0)
>                    for (int i = 0; i < c.Controls.Count; i++)
>                        ClearControl(c.Controls[i]);
>                else
>                    this.ClearControl(c);
>            
>        }
>
>        private void ClearControl(Control c)
>        {
>
>            if (c is TextBox)
>            {
>                TextBox tb = (TextBox)c;
>                tb.Text = "";
>            }
>
>            if (c is CheckBox)
>            {
>                CheckBox chk = (CheckBox)c;
>                chk.Checked = false;
>            }
>
>            if (c is ListView)
>            {
>                ListView lv = (ListView)c;
>                lv.Items.Clear();
>            }
>
>            if (c is DataGridView)
>            {
>                DataGridView dgv = (DataGridView)c;
>                dgv.Rows.Clear();
>            }
>        }
>
Looks good. :)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform