DataGridVew 儲存格之間拖曳範例

DataGridVew 儲存格之間拖曳範例

private void dataGridView2_CellMouseDown
   (object sender, DataGridViewCellMouseEventArgs e)
{
 dataGridView2.DoDragDrop(dataGridView2.Rows
   [e.RowIndex].Cells[e.ColumnIndex].Value.ToString(),
DragDropEffects.Copy);

}


private void dataGridView1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(System.String)))
                e.Effect = DragDropEffects.Copy;
            else
                e.Effect = DragDropEffects.None;
        } 


private void dataGridView1_DragDrop(object sender, DragEventArgs e) {
 if (e.Data.GetDataPresent(typeof(System.String)))
 {
 Point clientPoint = dataGridView1.PointToClient(new Point(e.X, e.Y));               
 dataGridView1.Rows[dataGridView1.HitTest(clientPoint.X, 
	clientPoint.Y).RowIndex].Cells[dataGridView1.HitTest(clientPoint.X,
 clientPoint.Y).ColumnIndex].Value = 
	(System.String)e.Data.GetData(typeof(System.String));  
  }                       
}

 

 

 

興滿逸筑2013年全新完工,位於恆春鎮外圍離市區只要2分鐘車程,有豪華的外觀、有美麗的庭院、也有溫馨舒適的房間,這裡車流量不多,空氣不錯,適合家族或成群結黨的朋友們一同旅遊的好地方。

http://sinmaniz.tw/index.html