Click here to Skip to main content
15,113,057 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I’m fairly new to c# programming so please bear with me. I’m currently working on a “simple” little program which allows the user to enter 25 values into the same text box and once this has been done I want to be able to display this 25 values in a list box as an array of 5 row by 5 column and i want to find out the largest number in the array.

private void button1_Click(object sender, EventArgs e)
    int arrayrows = 5;
    int arraycolomns = 5;
    int[,] arraytimes;
    arraytimes = new int[array rows, array columns];

    // list_Matrix.Items.Add(tb_First.Text);
    for (int i = 0; i != 5; i++)
        for (int j = 0; j != 5; j++)
           array times [i,j]= Convert. To String(Tb_First.Text);
            list_Matrix.Items.Add(array times[i, j].To String());



this is what i tried for displaying the array in a list box. but it isn't working.. since i dont find this i cant move to next section of finding the largest number among them. Any help will be much appreciated as i have hit a brick wall

Updated 4-Jun-13 22:30pm
Rockstar_ 5-Jun-13 3:29am
How are u entering the values in textbox?
Cinndrella2 5-Jun-13 3:31am
in the design box
Rockstar_ 5-Jun-13 3:32am
What you do is on enter key press event insert the value to array, like this accept all 25 values, and you will have all your 25 values in array. later you find the largest element in the array, after that print the array as a matrix using 2 for loops. If u don't know how to display in matrix then find some articles from net for dispalying an array in matrix, you will get lot of articles on that.
Tom Wauters 12-Jun-13 2:15am
How would you like to display your data in that listbox?

1 solution

The TextBox content (i.e. its Text property) is a string, hence you should first parse it in order to extract all the numbers (with String.Split method and Int32.TryParse you may easily accomlpish the task).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900