我使用该条语句dataGridView1.CurrentRow.Cells[0].Value来取得第一列的值,请问高手们如果第一列为空该如何判断,谢谢了!!!!!

解决方案 »

  1.   

    to 我使用该条语句dataGridView1.CurrentRow.Cells[0].Value来取得第一列的值,请问高手们如果第一列为空该如何判断,谢谢了!!!!!不能直接通过DataGridView去判断,你需要通过数据源然后进行判断。
    例如:
    BindingManagerBase bm = yourGridView.BindingContext[yourGridView.DataSource];
    DataRowView drv = bm.Current as DataRowView;
    if( drv[yourColumnName] == DBNull.Value )
    {
        //its value is null
    }
    else
    {
        //its value is not null
    }
      

  2.   

    If Me.DataGridView1.ColumnCount = 0 Then
            End If