我用强类型dataset绑定DataGridView,如何将选中的currentrow又付给强类型dataset的row呢

解决方案 »

  1.   

    直接可以去dataGridView的选中内容,最好这样
      

  2.   

    参考下下面的代码:
    DataGridViewRow row = (sender as DataGridView).Rows[e.RowIndex];
    DataRow dr = row.DataBoundItem as DataRow;
    if (dr == null)
    {
    DataRowView dv = row.DataBoundItem as DataRowView;
    if (dv != null)
    {
    dr = dv.Row;
    }
    }
      

  3.   

    粘全了吧:
    private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
    DataGridViewRow row = (sender as DataGridView).Rows[e.RowIndex];
    DataRow dr = row.DataBoundItem as DataRow;
    if (dr == null)
    {
    DataRowView dv = row.DataBoundItem as DataRowView;
    if (dv != null)
    {
    dr = dv.Row;
    }
    }
    }