我有一个datagridview,当我点击一个标题进行排序时,我得到以下错误,我无法弄清楚为什么。你们有什么想法我会得到以下错误吗?
Firearm Asset Management Studio.exe中出现“System.NullReferenceException”类型的异常,但未在用户代码中处理
private void firearmView_SelectionChanged(object sender, EventArgs e)
{
if (firearmView.SelectedRows.Count >= 0)
{
//Error above is found on the line directly below.
serialLabel.Text = firearmView.CurrentRow.Cells[0].Value.ToString();
manLabel.Text = firearmView.CurrentRow.Cells[1].Value.ToString();
modelLabel.Text = firearmView.CurrentRow.Cells[2].Value.ToString();
caliberLabel.Text = firearmView.CurrentRow.Cells[3].Value.ToString();
actionLabel.Text = firearmView.CurrentRow.Cells[4].Value.ToString();
priceLabel.Text = firearmView.CurrentRow.Cells[5].Value.ToString();
dataLabel.Text = firearmView.CurrentRow.Cells[6].Value.ToString();
sellLabel.Text = firearmView.CurrentRow.Cells[7].Value.ToString();
locationLabel.Text = firearmView.CurrentRow.Cells[8].Value.ToString();
ownerLabel.Text = firearmView.CurrentRow.Cells[9].Value.ToString();
valueLabel.Text = firearmView.CurrentRow.Cells[10].Value.ToString();
notesLabel.Text = firearmView.CurrentRow.Cells[11].Value.ToString();
}
}