Below code is to get the first column data from a datagrid, and do some string operation, but error showed,
NullReferenceException was handled Object reference not set to an instance of an object.
What is the problem ? If I want to get each data in the first column, how to do it?
private string getit(DataGrid grid)
{
StringBuilder stringStr = new StringBuilder();
for (int i = 0; i < grid.Items.Count; i++)
{
TextBlock selectTextBlockInCell = grid.Columns[0].GetCellContent(i) as TextBlock;
string inputName = selectTextBlockInCell.Text;
stringStr.Append(@"\pic () at (-0.5,");
stringStr.Append(3 - i);
stringStr.Append(inputName);
stringStr.Append(@"}");
}
return stringStr.ToString();
}