Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some textboxes in a panel on a form. Is it possible to do a double.Parse(txt.Text) for just these textboxes in the panel through a foreach?
Posted
Updated 27-Sep-12 22:04pm
v2
Comments
Kenneth Haugland 28-Sep-12 4:03am    
Pleas tag the question properly, WPF or WinForms or?
Frans Jan 28-Sep-12 4:04am    
Sorry, forgot to add that tag

Try this code:
C#
foreach (Control ctrl in panel1.Controls)
{
   if (ctrl is TextBox)
   {
      double dbl = Double.Parse(((TextBox)ctrl).Text);
   }
}
 
Share this answer
 
Comments
Espen Harlinn 29-Sep-12 6:56am    
5'ed!
Two Simple Approaches to WinForms Dirty Tracking[^] discusses an approach where you can loop through controls.

Check if these controls are textboxes and then parse the values for these controls.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900