2
How can I print an array in windows Forms? I tried by listbox using this code:
public void Mostrar_Grafo(int Qtdlinha,int Qtdcoluna, string[,] MAdjacencia)
{
ListBox listbox1 = new ListBox();
listbox1.Size = new System.Drawing.Size(400, 400);
listbox1.Location = new System.Drawing.Point(10, 10);
this.Controls.Add(listbox1);
listbox1.MultiColumn = true;
listbox1.BeginUpdate();
listbox1.Items.Add("Matriz de Adjacencia");
listbox1.Items.Add("");
for (int i = 0; i < Qtdlinha; i++)
{
for (int j = 0; j < Qtdcoluna; j++)
{
listbox1.Items.Add(" " + MAdjacencia[i, j] + " ");
}
}
}
But it keeps showing the numbers in a disorganized way as shown in the figure below:
i need you to show in matrix format like this example:
0 1 0 0 0 0 0
1 0 1 0 0 0 0
0 1 0 1 1 1 0
0 0 1 0 1 1 0
0 0 1 1 1 1 0
0 0 1 1 1 0 0
0 0 0 0 0 1 1