Hi to all,

I'm creating an application in which the form contains one datagridview and 20 pictureboxes.
When the DGV is populated, the user will drag a row from DGV and drop in any one of the pictureboxes.
The picturebox should able evaluate a column value(say column 1) from the dropping row and according to that it should change its picture.
Can anybody have an idea how to implement this...

Thnx in advance...

Regs,
Arunkumar

Assuming that column1 contains a path to the picture.
Here's what you can do.
First change the property AllowDragDrop to True for all the pictureboxes.
Then add this code:

Dim bMouseIsDown As Boolean = False
    Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            bMouseIsDown = True
        End If
    End Sub

    Private Sub DataGridView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseMove
        If DataGridView1.SelectedRows.Count > 0 Then
            If bMouseIsDown Then
                Dim path As String = DataGridView1.SelectedRows(0).Cells(1).Value
                DataGridView1.DoDragDrop(path, DragDropEffects.Copy)
            End If
        End If
    End Sub

'Repeat these two for all the pictureboxes
    Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.StringFormat) Then
            e.Effect = DragDropEffects.Copy
        End If
    End Sub

    Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
        Dim path As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
        Dim stream As New IO.FileStream(path, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
        Dim img As Image = Image.FromStream(stream)
        PictureBox1.Image = img
    End Sub

thnx..
this gives the basic..
from this i can develope my custom application..
resolved..

Your welcome. :)
Please do mark the thread as solved.

how to display image from datagridview in picturebox?????????? plz i need help

commented: Start your own thread. This is over a year old and not even the same topic. -2

Care to explain your question a bit further? Doesn't Oxiegen's post answer your question?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.