c # change source of picturebox

-2

I have a table with 4 Image fields. I put a pictureBox and in the Data properties, in DataBindings, linkei it with one of the table fields, the image1 field, while executing the program is bringing right the image of the image1 field of the table. So it can make changes, draw or delete, and when you click save, it will save the changes in the table field to which "image1" is linked.

How do I do the user, when I click a button, change which table field this pictureBox is linked to? For example, if you click on button 2, the pictureBox shows the image that is in the image2 field of the table, and any changes made, when you click save, will already save in "image2".

I'm using the local visual studio database, just dragging and dropping the fields from the "DataSources" panel. I do not use any sql code.

    
asked by anonymous 23.08.2017 / 00:55

1 answer

1

As I researched, you added Control.DataBindings to the Visual Studio graphical interface. With this, I believe you can simply clean up the collection and add another Source:

    private void button1_Click(object sender, EventArgs e)
    {
         pictureBox1.DataBindings.Clear();
         pictureBox1.DataBindings.Add("Image", SeuDataSet.Tables["suaTabelaDeImagens"], "coluna2");

    }

Documentation:

link

link

link

    
23.08.2017 / 01:19