Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2007, 06:05 AM
Authorized User
 
Join Date: Mar 2007
Location: Pune, Maharashtra, India.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Addition of Textbox in a UserControl

I have created a UserControl1

The control has 3textbox and 4labels
The outline is something like this

    TB1 TB2 TB3
      __________ __________ __________
s.No |__________| ÷ no = |__________| |__________|



The s.No,'÷', 'no' and '=' symbols are 4 labels and 3TextBox as shown
TB2, TB3 tabstop property is set to false, ReadOnly set to true and Modifer property is public


The purpose of this UserControl1 :
value(TB1) ÷ no = TB2
value(TB1) mod no = TB3

This is achieved using the follwing code :

private void textBox1_Leave(object sender, EventArgs e)
{

       if (textBox1.Text != "")
       {
textBox2.Text = (Convert.ToInt32(textBox1.Text) / Convert.ToInt32 (label3.Text) ).ToString();
textBox3.Text = (Convert.ToInt32(textBox1.Text) % Convert.ToInt32(label3.Text) ).ToString();

       }
}


Now I add the above UserControl1 dynamically to my project with
no = 15, Suppose if I add 3 objects of UserControl1 dynamically and enter nos 140, 151, 170 in TB1 I get following result as shown

      __________ __________ __________
   1 |__140_____| ÷ 15 = |___9______| |____5_____|
      __________ __________ __________
   2 |__151_____| ÷ 15 = |___10_____| |____1_____|
      __________ __________ __________
   3 |__170_____| ÷ 15 = |___11_____| |____5_____|
            -------------------------------
                |___30_____| |___11_____|

I want the addition of the Textboxes TB2 and TB3.
How can it be acheived ? I tried what dparsons explained me but it seems that it is not working for a UserControl.
His code given to me is as follow(Works perfectly for simple Textbox
but not for textboxs in UserControl)
foreach(Control ctrl in <parentControl>.Controls)
{
   if(ctrl is TextBox)
   {
      TextBox t = (TextBox)ctrl;
      string s;
      s = t.Text;
   }
}

Help Me..!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hexadecimal Addition madanshah16 XSLT 1 July 31st, 2007 07:21 AM
Addition in javascript m_soni21 VBScript 2 December 19th, 2006 11:06 AM
addition to errata luciano991 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 August 25th, 2006 08:29 PM
Converting AutoSuggest textbox to .NET UserControl gulbaek BOOK: Professional Ajax ISBN: 978-0-471-77778-6 7 July 3rd, 2006 10:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.