I have been doing an app to school - Vocabulary Trainer.
I have dataGridView
, where I keep the vocabulary.
I want to get the data from dataGridView
to a multidimensional array. I used this code for it:
string[,]word = new string[tableDataGridView.Rows.Count, tableDataGridView.Columns.Count];
for (int x = 0; x < word.GetLenght(0); x++)
{
for (int i = 0; i< word.GetLenghth(1); i++)
{
word[x,i] = tableDataGridView.Rows[x].Cells[i].Value.ToString();
}
{
Data save from dataGridView
to multidimensional array, but the exception: "NullReferenceException was unhandled" is thrown and the piece of code:
word[x,i] = tableDataGridView.Rows[x].Cells[i].Value.ToString();
is highlighted. I would be glad if someone help me out.