0
양식 응용 프로그램의 groupbox 안에 datagridview가 있습니다. 나는이 코드를 만들었다.Datagridview Combobox 값
private bool checkrow(DataGridViewRow testrow)
{
for (int i = 0; i < testrow.Cells.Count; i++)
{
if (testrow.Cells[i].Value != null)
{
MessageBox.Show(testrow.Cells[i].Value.ToString());
if (testrow.Cells[i].Value.ToString() != string.Empty)
{
MessageBox.Show(testrow.Cells[i].Value.ToString());
return true;
}
}
}
return false;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (checkrow(dgvTimeTracker.CurrentRow) == true)
{
string cbtext = dgvTimeTracker.Rows[dgvTimeTracker.SelectedCells[0].RowIndex].Cells[1].Value.ToString();
MessageBox.Show(cbtext);
string[] newrow = new string[] { DateTime.Now.ToShortDateString(), cbtext, DateTime.Now.ToLongTimeString(), "", "", "" };
}
else
{
MessageBox.Show("Error!");
}
}
이 코드를 새 프로젝트에서 실행하면 완벽하게 실행됩니다. 하지만 내 다른 프로젝트에서 그것을 실행하는 경우에만 "오류"메시지 또는 nullreference 예외를 반환합니다 콤보 상자 항목 {1}의 값을 얻을 때 데이터 격자의
아무도 도와주세요 ??
들여 쓰기가 일관된 코드를 게시하면 도움이됩니다. 코드를 읽기가 어렵다면 사람들이 당신을 도울 수 있도록하는 것이 더 어렵습니다. – jmcilhinney