zoukankan      html  css  js  c++  java
  • 关于C# 将DataGridView数据拖动到picturebox代码示例

    this.PictureBoxNodeBackImage.AllowDrop = true; //这个也要加上
    //最后我们判断完成后怎样向PictureBox中添加数据,并从datagridview中删除选中数据所在的行,我们在PictureBox的DragDrop事件中执行操作
    private void PictureBoxNodeBackImage_DragDrop(object sender, DragEventArgs e)
    {
    Point pos = new Point(e.X, e.Y);   //拖動數據后 所記錄的坐標
      pos = this.PictureBoxNodeBackImage.PointToClient(pos);

    int index = -1;
    if (e.Data.GetDataPresent(typeof(int)))
    {
    index
    = (int)e.Data.GetData(typeof(int));
    }
    if (index > -1)
    MessageBox.Show(DataGridViewleizhi.Rows[index].Cells[
    "Id"].Value.ToString());
    }
    //再次确定当数据拖动到PictureBox上方时,判断数据格式以及目标对象,和拖动方式.我们在PictureBox的DragEnter 事件中进行判断
    private void PictureBoxNodeBackImage_DragEnter(object sender, DragEventArgs e)
    {
    if (e.Data.GetDataPresent(typeof(int)))
    {
    e.Effect
    = DragDropEffects.Copy;
    }
    else
    {
    e.Effect
    = DragDropEffects.None;
    }
    }
    private void DataGridViewleizhi_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
    {
    DataGridViewleizhi.DoDragDrop(e.RowIndex, DragDropEffects.Copy);
    }
  • 相关阅读:
    无标题
    UVA 11987 并查集删点
    屯题 (bestcoder #62~#75)
    codeforces 293E Close Vertices 点分治+滑窗+treap
    hdu4670 Cube number on a tree 点分治
    hdu4812 D Tree 点分治
    poj2112 Boatherds 点分治
    HDU 4866 Shooting 二分+主席树
    poj1741 Tree 点分治
    关于点分治。。。
  • 原文地址:https://www.cnblogs.com/yannis/p/2059023.html
Copyright © 2011-2022 走看看