Resim – image – Bitmap Sürükle Bırak (Drag-Drop) Örneği — Csharp — C#

Resim – image – Bitmap Sürükle Bırak (Drap-Drop) Örneği — Csharp — C#

 


resim_surukle_birak

 

resim_surukle_birak2

Resim ekle ile picturebox a resim ekliyoruz.

resim_surukle_birak3

Mouse ile sürekle bırak yöntemiyle ikinci picturebox  resimi taşıyoruz.

 

[code lang=”csharp”]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;//www.gorselprogramlama.com
using System.Windows.Forms;

namespace suruklebirakform
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();//www.gorselprogramlama.com
ofd.Filter = "sadece jpg|*.jpg";
if (ofd.ShowDialog()==DialogResult.OK)
{
string resimyolu = ofd.FileName;
pictureBox1.ImageLocation = resimyolu;
}
}

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
pictureBox1.DoDragDrop(pictureBox1.Image, DragDropEffects.Copy | DragDropEffects.Move);
}

private void panel1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Bitmap))
{
e.Effect = DragDropEffects.Copy;
}
}

private void panel1_DragDrop(object sender, DragEventArgs e)
{
panel1.BackgroundImage =(Bitmap) e.Data.GetData(DataFormats.Bitmap);
pictureBox1.Image = null;
}//www.gorselprogramlama.com
}
}

[/code]

 

Projeyi İNDİR

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir