wyświetlanie tablicy w textboxie

0

Witam

Mam mały problem - mianowicie, jak mogę wyświetlić zawartość mojej tablicy do textboxa? Aby przypominało to chociaż tablicę 2x2 - kolumny i wiersze, odstępy między każdym elementem.

Inna sprawa - podobna - jak mogę wyświetlić zawartość listy w tymże textboxie, jeden element pod drugim, ewentualnie obok siebie?

textbox ma już multiline i atrybut readonly.

pzdr!

0

Wyświetlanie tablicy:

int[][] matrix = new int[4][4];

for (int y = 0; y < matrix.Length; y++)
{
    string line = string.Empty;
    for (int x = 0; x < matrix[y].Length; x++)
    {
        line += matrix[y][x] + " ";
    }
    textBox1.Lines.Add(line);
}

Analogicznie z listą.

0

Error 1 'System.Array' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)

dla linii (.Add podkreślone):

                textBox1.Lines.Add(line); 

co jest nie tak?

1

Kurcze, byłem pewny, że posiada Add, a jednak. No to po prostu zamiast tego daj:

textBox1.AppendText(line + "\n");

1 użytkowników online, w tym zalogowanych: 0, gości: 1