CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Generating Text Box at runtime!!

    Code:
    
            int[,] aA1 = new int[3, 4];
            Random sRan = new Random();
    
                int i, j,jdis,xis=40; 
                for (j = 0; j < 4; j++)
                {
                    for (i = 0; i <3; i++)
                    {
                        try
                        {
                            aA1[i, j] = sRan.Next(0, 9);
    
                        }
                        catch (IndexOutOfRangeException)
                        {
                            MessageBox.Show("Error!");
                        }
                    }
                }
    
    
     System.Drawing.Graphics graphicsObj;
    
                        graphicsObj = this.CreateGraphics();
    
                        Font myFont = new System.Drawing.Font("Helvetica", 16, FontStyle.Italic);
    
                        Brush myBrush = new SolidBrush(System.Drawing.Color.Red);
    
                        for (jdis = 0; jdis < 4; jdis++)
                        {
                            graphicsObj.DrawString(aA1[0, jdis].ToString(), myFont, myBrush, xis, 80);
                            graphicsObj.DrawString(aA1[1, jdis].ToString(), myFont, myBrush, xis, 105);
                            graphicsObj.DrawString(aA1[2, jdis].ToString(), myFont, myBrush, xis, 130);
                            graphicsObj.DrawString(aA1[3, jdis].ToString(), myFont, myBrush, xis, 155);
                            graphicsObj.DrawString(aA1[4, jdis].ToString(), myFont, myBrush, xis, 180);
                            graphicsObj.DrawString(aA1[5, jdis].ToString(), myFont, myBrush, xis, 205);
                            graphicsObj.DrawString(aA1[6, jdis].ToString(), myFont, myBrush, xis, 230);
                            graphicsObj.DrawString(aA1[7, jdis].ToString(), myFont, myBrush, xis, 255);
                            xis += 30;
                        }
    Code:
                   1                 5                  7                 8
                   2                 4                  5                 2 
                   3                 5                  6                 5
              |txtbox|           |txtbox|           |txtbox|            |txtbox|
     
    
    I want to create some thing like this............
    This code Up here creates and assigns the value for a 8X25 matrix and displays it in the form of my application but can I generate a Textbox just below every Column at the runtime as it does after showing the runtime....and The textbox below should be recognised by the index of the column ...... Please Help me out Here.....

    BTW what is wrong with this code?? because at first my program runs fine but if i close this form (not application) in which numbers are printed and again open it nothing appears .....but this is totally random because sometime if you get lucky it may again appear on the second attempt too...........
    Last edited by rocky_upadhaya; January 31st, 2010 at 04:26 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured