10 Replies - 1133 Views - Last Post: 26 November 2015 - 11:41 AM Rate Topic: -----

#1 R3Z  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 121
  • Joined: 19-November 15

DatagridView PictureBox

Posted 25 November 2015 - 10:27 PM

hey guys need some help



in the datagridview click event how can i load a picture into a picturebox by the way im using access

example let say i click apple i want a picture of an apple to load on a picturebox


Me.PictureBox1.Load(Me.Datagrid.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)


this code works only if i hit the picture text not the name

Is This A Good Question/Topic? 0
  • +

Replies To: DatagridView PictureBox

#2 sam.ganjavi  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 75
  • Joined: 03-September 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 06:50 AM

Hi
From the code you have put, the picture is loaded from the data in the column that was clicked. If you click on a different row, is the data the same as the data in the picture name.

Instead of using

Quote

Me.PictureBox1.Load(Me.Datagrid.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)


change the e.ColumnIdex to the picture text column index

      dim myColumnIndex as integer = X 'X represents the column index for the picture path or info
      Me.PictureBox1.Load(Me.Datagrid.Rows(e.RowIndex).Cells(myColumnIndex).Value)


This post has been edited by sam.ganjavi: 26 November 2015 - 06:50 AM

Was This Post Helpful? 0
  • +
  • -

#3 R3Z  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 121
  • Joined: 19-November 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 09:52 AM

 Dim myColumnIndex As Integer = "C:\Users\M\Facturación\Facturación\Data\LecheRica.JPG"
        Me.PictureBox1.Load(Me.DGVProductos.Rows(e.RowIndex).Cells(myColumnIndex).Value)


getting an error
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6492
  • View blog
  • Posts: 26,268
  • Joined: 12-December 12

Re: DatagridView PictureBox

Posted 26 November 2015 - 10:03 AM

What error.
Was This Post Helpful? 0
  • +
  • -

#5 sam.ganjavi  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 75
  • Joined: 03-September 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 10:04 AM

View PostR3Z, on 26 November 2015 - 11:52 AM, said:

 Dim myColumnIndex As Integer = "C:\Users\M\Facturación\Facturación\Data\LecheRica.JPG"
        Me.PictureBox1.Load(Me.DGVProductos.Rows(e.RowIndex).Cells(myColumnIndex).Value)


getting an error


It is obviously getting an error you cannot assign string to an integer.

The question is that where is the path of your image, if the path is inside a column, then you pass the value of that column to your pictureBox. but if the path is outside of the datagridview then you just pass the string value.
Was This Post Helpful? 0
  • +
  • -

#6 R3Z  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 121
  • Joined: 19-November 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 11:05 AM

thanks now i got it

thanks alot sam

one question how can i make the photo column not visible

my database is like this :

IdProduct Name Quantity Price Category Photo

how do i make it like this:

IdProduct Name Quantity Price Category

This post has been edited by R3Z: 26 November 2015 - 11:14 AM

Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6492
  • View blog
  • Posts: 26,268
  • Joined: 12-December 12

Re: DatagridView PictureBox

Posted 26 November 2015 - 11:14 AM

An if statement doesn't declare anything, you have to explain what you mean.
Was This Post Helpful? 0
  • +
  • -

#8 R3Z  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 121
  • Joined: 19-November 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 11:24 AM

my database is like this :

IdProduct Name Quantity Price Category Photo

how do i make it like this:

IdProduct Name Quantity Price Category


I want to make the photo column not visible

This post has been edited by R3Z: 26 November 2015 - 11:24 AM

Was This Post Helpful? 0
  • +
  • -

#9 sam.ganjavi  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 75
  • Joined: 03-September 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 11:32 AM

To make a column invisible just set the visible to false

Me.DGVProductos.Columns("Photo").Visible = False  ' Using Column Header name 

Me.DGVProductos.Columns(5).Visible = False  ' Using Column Index 



Was This Post Helpful? 1
  • +
  • -

#10 R3Z  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 121
  • Joined: 19-November 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 11:38 AM

nevermind got it to work


put the code in cell enter



thank you very much sam for taking your time to help me out

This post has been edited by R3Z: 26 November 2015 - 11:42 AM

Was This Post Helpful? 0
  • +
  • -

#11 sam.ganjavi  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 75
  • Joined: 03-September 15

Re: DatagridView PictureBox

Posted 26 November 2015 - 11:41 AM

You put it after the data is loaded.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1