I'm trying to display something like this, in the textbox.
Name Test Basket Destructive Final Grade
--------------------------------------------------
Alex 0 0 0 0
Danny 0 0 0 0
Dave 0 0 0 0
This is what I'm getting:
Name Test Basket Destructive Final Grade
--------------------------------------------------
Alex 0 0 0 0
Danny 0 0 0 0
Dave 0 0 0 0
It's worse than that because I think the 0's are in the wrong place.
The idea is to have the columns at the top, and underneath it should look something like:
Name - Grade 1 - Grade 2 - Grade 3 - Final Grade
What am I doing wrong?
I'm absolutely awful at for loops too which is why I think the 0's are in the wrong place.
string[] Columns = { "Name","Test", "Basket","Destructive","Final Grade"};
string[] Names = { "Alex", "Danny", "Dave", "Goerge", "Hannan", "Ian", "Muna" };
int[,] Grade = new int[7, 3];
int[] FinalGrade = new int[7];
private void uiShowMarksAZButton_Click(object sender, EventArgs e)
{
//test
Grade[0, 0] = 10;
//test
uiMarksDisplayTextBox.Text = string.Join("\t", Columns);
uiMarksDisplayTextBox.Text += System.Environment.NewLine;
for (int i = 0; i < Names.Length; i++ )
{
uiMarksDisplayTextBox.Text += (Names[i]);
for (int x = 0; x < 3; x++)
{
uiMarksDisplayTextBox.Text += ("\t" + Grade[x, x]);
}
uiMarksDisplayTextBox.Text += System.Environment.NewLine;
}
}
EDIT 1: to add some clarification, I am been given the layout of the form by my professor, I am not allowed to change it, or the textbox, meaning I cannot use datagrids or listviews.
When I input Alex's grades, it looks something like this:
Name Test Basket Destructive Final Grade
-------------------------------------------------
Alex 10 0 0
Danny 10 0 0
Dave 10 0 0
George 10 0 0
Hannan 10 0 0
Ian 10 0 0
Muna 10 0 0
How come all the 0's are in the wrong place?
sting.Formatis very strange choice for WinForms where so many rich table layout controls exist.Monospacefont on theTextBox. That should do the trick.