i have a gridview and i am trying to load up the list with a column from the grid view and i m getting a null reference exception
i have tried this
public static List<string> LoadStringList()
{
List<string> stringList = new List<string>();
if (contactDataGridView.RowCount != 0)
{
for (int i = 0; i < contactDataGridView.Rows.Count; i++)
{
stringList.Add((string)contactDataGridView.Rows[i].Cells[2].Value);
}
}
return stringList;
}
and i tried this
public static List<string> LoadStringList()
{
List<string> stringList = new List<string>();
if (frmPRG299.mainForm.contactDataGridView.RowCount != 0)
{
for (int i = 0; i <frmPRG299.mainForm.contactDataGridView.Rows.Count; i++)
{
stringList.Add((string)frmPRG299.mainForm.contactDataGridView.Rows[i].Cells[2].Value);
}
}
return stringList;
}
farther explanation
i have two forms frmMain and frmSub where the gridview is in frmMain and a combobox in frmSub i need to call the function LoadStringList()
to populate the Combobox