dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Inserting textbox values in table

  1. #1
    Join Date
    Jul 2009
    Posts
    2

    Inserting textbox values in table

    Hi!!!
    I am making a window application in which there is a textbox in which we have to enter only numeric values...
    How can I display a table on the form which has columns - ones,tens,hundred ,thousand,ten thousand,lakh , ten lakh etc. Now whatever number we enter in textbox that number should automatically get filled in this numeration table ....
    For example , number entered is 2589,then in table 9 should be in ones column , 8 in tens, 5 in hundreds, 2 in thousands column................


    How can I do this.....

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Inserting textbox values in table

    You will use a GridView control to display the table. A simple logic to do this would be to convert the number into a string and then use SubString() method to get the ones, tens, hundreds, etc.

  3. #3
    Join Date
    Jul 2009
    Posts
    2

    Re: Inserting textbox values in table

    There is no database connectivity..........
    Simply a number is entered in textbox and I want that number to be displayed in table

  4. #4
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Re: Inserting textbox values in table

    yes it is not necessary to use GridView for this problem.

    i wrote this code for you:

    Code:
        private void button1_Click(object sender, EventArgs e)
            {
                string number = textBox1.Text;
                char[] digits = number.ToCharArray();
    
                int pos = 0;
                foreach (char d in digits)
                {
                    Control cnt = tableLayoutPanel1.GetControlFromPosition(pos,1);
                    Label lbl = (Label)cnt;
                    lbl.Text = d.ToString(); 
                    pos++;
    
                    
                }
            }
    to get the code work please add TableLayoutPanel to your form with 2 rows and 4 columns (first row canbe used as header for titles) then put lables in every cells and change the name of the lables in the first row to the tiles you want like (1s,10s,100s etc.)
    Please rate my post if it was helpful for you.
    Java, C#, C++, PHP, ASP.NET
    SQL Server, MySQL
    DirectX
    MATH
    Touraj Ebrahimi
    [toraj_e] [at] [yahoo] [dot] [com]

  5. #5
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Inserting textbox values in table

    Quote Originally Posted by vinnijain View Post
    There is no database connectivity..........
    Simply a number is entered in textbox and I want that number to be displayed in table
    GridView does not mean that you have to have a database connectivity. You can use GridView for anything where a table can be used.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)