473,388 Members | 1,215 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

PictureBox Binding

Hi All,

I've been working on a form that has several bound
controls that all link to one table in a dataset. In the
table, there is a column for the filename of jpeg images
related to each record. I have a combobox which displays
the key for each record so that the user can select an
item and all the other controls update. So far i have
the combobox, a label and a textbox all bound and working
correctly when a user selects an item. I have a
pictureBox on the form however that i wish to be bound to
the filename field for the specific row. Does anybody
know how to do this?

Thanks in advance,
Jesse

ps. I don't want to put a BLOB field in the database for
the images and do it that way.
Jul 21 '05 #1
3 2921
Cor
Hi Jesse,

You have to streamread it to get it in your picturebox (even if you use a
blobfield)

I think that you can not bind real in a productive way.

So in my opinion you only can use the changing events to read it.

But just my thought about it

Cor


I've been working on a form that has several bound
controls that all link to one table in a dataset. In the
table, there is a column for the filename of jpeg images
related to each record. I have a combobox which displays
the key for each record so that the user can select an
item and all the other controls update. So far i have
the combobox, a label and a textbox all bound and working
correctly when a user selects an item. I have a
pictureBox on the form however that i wish to be bound to
the filename field for the specific row. Does anybody
know how to do this?

Thanks in advance,
Jesse

Jul 21 '05 #2
Thanks cor for your suggestions.

I have found a way though which does not involve streams
(because i didn't want to use BLOB fields).

What i have done is this (if you wish to know):

'Members
Private WithEvents m_PictureBinding As Binding
Private currentImageFile As String

'This binds the pictureBox (picBikePics)
Private Sub BindControls()
m_PictureBinding = New Binding("Image", dsAll.Tables
(0), "Filename")
picBikePics.DataBindings.Add(m_PictureBinding)
End Sub

'This method gets fired everytime the above Binding
object (m_PictureBinding) row is changed and is used to
place the correct value back in the database before
continuing. (In my case, i don't want to change the
database field at all so i set it to what it was
originally which i set in the method "Format") Private
Sub m_PictureBinding_Parse(ByVal sender As Object, ByVal
e As System.Windows.Forms.ConvertEventArgs) Handles
m_PictureBinding.Parse

e.Value = currentImageFile

End Sub

'This method gets fired everytime that same object is
changed but is used to make sure the value going into the
control from the database is of the right type for the
Image property on the control. So i have to convert the
filename string to an Image object.
Private Sub PictureBox_Format(ByVal sender As Object,
ByVal e As ConvertEventArgs) Handles
m_PictureBinding.Format

currentImageFile = CStr(e.Value)
e.Value = Image.FromFile(CStr(e.Value))

End Sub

Anyways, thanks again.
Hope u got something out of it. I did.

Jesse

-----Original Message-----
Hi Jesse,

You have to streamread it to get it in your picturebox (even if you use ablobfield)

I think that you can not bind real in a productive way.

So in my opinion you only can use the changing events to read it.
But just my thought about it

Cor


I've been working on a form that has several bound
controls that all link to one table in a dataset. In the table, there is a column for the filename of jpeg images related to each record. I have a combobox which displays the key for each record so that the user can select an
item and all the other controls update. So far i have
the combobox, a label and a textbox all bound and working correctly when a user selects an item. I have a
pictureBox on the form however that i wish to be bound to the filename field for the specific row. Does anybody
know how to do this?

Thanks in advance,
Jesse

.

Jul 21 '05 #3
Cor
Hi Jesse,

Although I never used the event you are using, it was the solution I was
thinking on when I saw your problem. (Not that I would do it that way, but
in the way that you are making your program I would)

(Sometimes I see answers people telling this, and I do not believe that is
true, but you can trust me that is something I do not do).

Cor

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cade Carvell | last post by:
Hello, I have a class that I have a public property on it for an Image. In my class I change the image, different image etc. Anyway, Everythign works fine for the first image. I an bind the...
0
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for...
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
3
by: Jesse | last post by:
Hi All, I've been working on a form that has several bound controls that all link to one table in a dataset. In the table, there is a column for the filename of jpeg images related to each...
1
by: Joe Spears | last post by:
Hi Is there a simple way to bind a PictureBox image to a datatable?? I've tried pictureBox.DataBindings.Add("BackgroundImage", dt1, "Picture"); But it doesn't seem to work. Do I have to go...
2
by: Ryan | last post by:
I have a very basic form that has controls bound to a SQL 2005 database for an Employee Directory. I'm using a PictureBox control to bind to the "Photo" field which is of datatype image. However,...
0
by: dlamar | last post by:
I'm using VB.NET with 2.0 - I have a number of PictureBoxes in my application - all of which use a context menu to change the associated Image to one of 5 options. I need to maintain the state of...
4
by: munibe | last post by:
Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named customer_button, my wish is to add a new small...
5
by: AWW | last post by:
XP VB 2005 running an example from help that creates a picturebox in code - the picturebox is not created. If I comment out the "Dim Box as New PictureBox" and create it in Design mode - the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.