473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

sum the values from dynamically formed textboxes

Hi

I managed to dynamically form textboxes using c#. I want include another button, whenever i enter any values in those textboxes i should get sum in message box. i donno how to use code for dynamic texboxes. This is what i have done,
Expand|Select|Wrap|Line Numbers
  1. namespace WindowsFormsApplication1
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.  
  10.         private void button1_Click(object sender, EventArgs e)
  11.         {
  12.             int y=50;
  13.             int j = int.Parse(textBox1.Text);
  14.             TextBox[] txt = new TextBox[j];
  15.             if (j < 20)
  16.             {
  17.                 for (int i = 0; i < j; i++)
  18.                 {
  19.                     txt[i] = new TextBox();
  20.                     txt[i].AutoSize = true;
  21.  
  22.                     txt[i].Location = new Point(150, y);
  23.  
  24.                     this.Controls.Add(txt[i]);
  25.                     y = y + 30;
  26.  
  27.                 }
  28.             }
  29.             else
  30.             {
  31.                 MessageBox.Show(" enter values below 20");
  32.             }
  33.         }
  34.  
  35.         private void button2_Click(object sender, EventArgs e)
  36.         {
  37.  
  38.         }
  39.  
  40.         private void Form1_Load(object sender, EventArgs e)
  41.         {
  42.  
  43.         }
  44.  
  45.     }
  46. }
  47.  
What code should i use to add the values in the textbox
Aug 7 '08 #1
3 1489
Plater
7,872 Expert 4TB
Seems pretty basic?
Get value from textbox.
Convert to a number
Add number.

???
Aug 7 '08 #2
Seems pretty basic?
Get value from textbox.
Convert to a number
Add number.

???
I am just a learner, i donno how to get the value from the textbox?
Aug 13 '08 #3
Plater
7,872 Expert 4TB
I am just a learner, i donno how to get the value from the textbox?
http://www.google.com/search?hl=en&q=.NET+gui+tutorial
Aug 13 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mark Broadbent | last post by:
This one has got me absolutely stumped. At work I have created a simple web form that gets data from a sql backend and puts this to a dataset. I have an edit button that when clicked will set...
3
by: SD | last post by:
Hello, I have a form that has a panel container where I'm adding textboxes dynamically based on a query to database, so I'm looping through the records. The problem I have is that once built,...
5
by: \A_Michigan_User\ | last post by:
I'm using asp.net/vb.net/ado.net to create a very simple user interface. (Everything works if I use STATICALLY created textBoxes... but not when I make them DYNAMICALLY.) 1. Execute a SQL...
1
by: KasperBirch | last post by:
Hi NG Im trying to read the values of a bunch of TextBox'es that I add in a loop, dynamically. The page has an <asp:Table id="table" ...> control, and I add rows with textboxes like this (from...
5
by: BLACKDOG157 | last post by:
I've made a form with a variable number of textboxes. The user fills them out, and then I need to pick up the values he has filled in. The number of textboxes vary depending on a value that the...
1
by: brendwal | last post by:
Hi, I am stumped at how to do this: I have a simple webform that I want the user to enter one value (an address). I then want the form to send those values to a PHP script that processes the...
2
by: phpachu | last post by:
Hi, I hav created a group of textboxes using a loop and its names are unique and names are assigned using variable ( like <input type=text name=$name1>). Then How can i retrieve the values in...
1
by: JFKJr | last post by:
Hello everyone, the following Access VBA code opens an excel file and creates textboxes in a given range of cells dynamically. The code attaches "MouseUP" and "Exit" events to the textboxes (using...
3
by: cubekid | last post by:
Dev't Tool: Visual C# 2003 and Javascript System Type: Web Application One requirement of the system is to dynamically create a table on client-side (Javascripting using createElement method.)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.