在单击DataGirdView的内容事件里面写代码如下:textbox1.text = this.dataGridView1.CurrentRow.Cells[索引列].Value.ToString(); 不成功找我
用CELL单元格的索引寻址,直接赋String
可以设置DataGridView的SelectionMode属性为FullRowSelect 实现左键点击选取整行,右击的话就需要在鼠标点击事件里面实现了 如下:private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.
dataGridView1的CellClick事件,获取当前你点击的单元格文本方法,如string value=dataGridView1.CurrentCell.Value.ToString();dataGridView1.CurrentCell.Value是object类型,什么类型你强制转换
使用dataGridView1_CellClick事件此事件参数(object sender,DataGridViewCellEventArgs e) this.dataGridView1.CurrentRow.Cells[e.ColumnIndex].Value.ToString(); e.ColumnIndex获得你所点击的这个单元格的列索引号.
int a = dataGridView1.SelectedRows.Index; //获取选中的行 string text=dataGridView1.Rows[a].Cells[0].Value; //获取选中行内第一个单元格内的值
GridView1_RowDataBound事件里面if(GridView1.Rows.Count>0){//执行操作}else{MessBox.show("");}
(1)将datagridview的selectionmode设置为fullrowselection (2)添加selectionchanged事件
选中是用什么选中的CheckBox?GridView的RowDataBound事件CheckBox cbk=(CheckBox)e.Row.FindControl("CheckBox的ID");if(cbk.Checked){Response.Write(e.Row.Cell[列].Text);}e.Row.Cell[列].Text通过这里获取列的值列的索引从0开始也就是第一列应该e.Row.Cell[0].Text 这样写当前列不能为模版列
其实有一个简单的方法: 1)使用sqldataadapter的fill方法把数据先全部灌入到datatable中. 2)拖拽一个datagridview到页面上,然后点击右上角的小箭头,选择“编辑列”,然后根据已知数据库的列类型(比如bit类型的应该是添加