473,811 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sum the values from dynamically formed textboxes

7 New Member
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 1515
Plater
7,872 Recognized Expert Expert
Seems pretty basic?
Get value from textbox.
Convert to a number
Add number.

???
Aug 7 '08 #2
ashwinigopi
7 New Member
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 Recognized Expert Expert
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
1802
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 the relevant text properties of several textboxes (to allow for edit) ....all simple so far. I have a save button that when clicked will then perform the writing back of the text in the textboxes. The problem is (and having debugged I see this)...
3
1249
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, I need to pass those textboxes values to another for to build the parameters for a report. Here is the sample:
5
2596
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 SELECT cmd to retrieve a record. 2. Loop through the dataReader values, creating textBox boxes dynamically, adding them to a Panel. (The database values are placed in these textboxes.)
1
1239
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 memory, never mind syntax): for (int i = 0; i<10; i++) {
5
1713
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 user filled in in another page. But suppose there were 3 values. In that case, I know the names of the fields, they are MyTextBox1 MyTextbox2 MyTextbox3
1
3037
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 address and returns 2 numeric values back to the original webform populating two textboxes in a second form on the orginal page. I have the PHP script working to calculate the values, but I don't know how to send them properly and return the new...
2
5925
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 that textboxes after a button click with in a loop. Really I cant move from here. Can anyone plz help me.. Part of the my code is given below <html> <table> <?php // i hav an array "assocArray" and its count is "countarray" for($i = 1; $i <...
1
6343
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 the following "DateTextBox" class module). Whenever a user enters in to the textbox, the code displays "Please enter date in mm/dd/yyyy format (for ex: 01/01/2009)." message which is accomplished using "MouseUp" event. And, I used "Exit" event to...
3
2987
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.) The table has textboxes inside each cell. a few sample code: for (i = 0; i < 4; i ++) // four columns { textBoxes = document.createElement("INPUT");
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10124
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.