DataGridView鼠标的拖放操作及单元格编辑结束数据复制与单元格单击数据粘贴及两个DataGridView相互拖放操作
2013-10-24 07:51
519 查看
昨天观世音菩萨出家纪念日,昨晚上本想发布的,一忙其他事情给忘了,今早补上,以资纪念.2013年10月23日:二〇一三年九月十九
DataGridView鼠标的拖放操作及单元格编辑结束数据复制与单元格单击数据粘贴及两个DataGridView相互拖放操作 private void DataGridView1_DragEnter(object sender, DragEventArgs e) { e.Effect = (e.Data.GetDataPresent(typeof(System.String)) && DataGridView1.Rows.Count > 0) ? DragDropEffects.Copy : DragDropEffects.None; } private void DataGridView1_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(System.String)) && DataGridView1.Rows.Count > 0) { Point 二维面 = DataGridView1.PointToClient(new Point(e.X, e.Y)); DataGridView1.Rows[DataGridView1.HitTest(二维面.X, 二维面.Y).RowIndex].Cells[DataGridView1.HitTest(二维面.X, 二维面.Y).ColumnIndex].Value = (System.String)e.Data.GetData(typeof(System.String)); } } private void DataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { string 单元值 = ""; if (DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) 单元值 = DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); DataGridView1.DoDragDrop(单元值, DragDropEffects.Copy); } private void DataGridView2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { DataGridView2.DoDragDrop(DataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(), DragDropEffects.Copy); } private void DataGridView2_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(System.String)) && DataGridView2.Rows.Count > 0) { Point 二维面 = DataGridView2.PointToClient(new Point(e.X, e.Y)); DataGridView2.Rows[DataGridView2.HitTest(二维面.X, 二维面.Y).RowIndex].Cells[DataGridView2.HitTest(二维面.X, 二维面.Y).ColumnIndex].Value = (System.String)e.Data.GetData(typeof(System.String)); } } private void DataGridView2_DragEnter(object sender, DragEventArgs e) { e.Effect = (e.Data.GetDataPresent(typeof(System.String))) ? DragDropEffects.Copy : DragDropEffects.None; } private void DataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e) { string 单元值 = DataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); DataGridView2.DoDragDrop(单元值, DragDropEffects.Copy); } 最后顺便说一下,如果richTextBox控件的属性EeableAutoDragDrop设置为True则可以拖放数据到DataGridView中。
相关文章推荐
- C# winform datagridview中如何实现鼠标右键点击一行数据出现一个带有删除的菜单,并能执行删除操作?
- 在GridView中针对鼠标单击的某一独立单元格进行编辑
- Excel学习笔记002-002:工作表内及工作表间、工作簿间单元格数据的复制、剪切、粘贴;如何进行成绩排序。
- 【来日复制粘贴】以符号作为换行依据将一个单元格具有分隔符的一串数据变成数排
- Excel学习笔记002-002:工作表内及工作表间、工作簿间单元格数据的复制、剪切、粘贴;如何进行成绩排序。
- DataGridView 结束编辑不用鼠标点其它地方
- 在GridView中针对鼠标单击的某一独立单元格进行编辑
- [翻译]在GridView中针对鼠标单击的某一独立单元格进行编辑
- 用有名管道实现文件复制,有两个终端 ,一个进行复制操作,另一个进行粘贴操作
- [翻译]在GridView中针对鼠标单击的某一独立单元格进行编辑
- dataGridView操作数据(增加 读取 绑定 获取选择的单元格 选中整行单元格时颜色变换 更新数据 锁定列的位置 添加行 列头的方法)
- [翻译]在GridView中针对鼠标单击的某一独立单元格进行编辑
- 在GridView中针对鼠标单击的某一独立单元格进行编辑
- sql/pl基本操作】【登陆】【格式化table显示】【两个数据库表复制数据】【格式化输出】
- 在GridView中针对鼠标单击的某一独立单元格进行编辑总结
- [翻译]在GridView中针对鼠标单击的某一独立单元格进行编辑
- linux 下 vi 文本编辑如何复制一行粘贴删除一行数据
- U6数据导出工具项目总结三 鼠标单击或者双击DataGridView控件时获取鼠标点击位置的值
- 在GridView中针对鼠标单击的某一独立单元格进行编辑
- Orcad原理图封装库批量编辑引脚时需要配合Excel进行制作时候需要操作(遇到无法复制粘贴操作)