private void dataGridView1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataGridViewRow)))
{ UserLogin user = Login.GetLogin();
Invite.InviteM(user.SessionId, DBHelper.userId);//发送邀请信息
} }得到的DataGridViewRow里有一列Id,怎么把这列id读取出来?
datagridview.rows[i].cell[0].tostring()
int QuestionId = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ColumnId"].Value.ToString());
遍历所有行,获取checkBox选中的Id
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
if (dr.Cells[0].Value != null)
{
if ((bool)dr.Cells[0].Value == true)
{
int Id = Convert.ToInt32(dr.Cells["ColumnId"].Value.ToString());
string State = dr.Cells["ColumnState"].Value.ToString();
}
}
}