1.Hello
2.I'm trying to complete a hobby of mine where if  I make a selection
from a  comboBox that will select from a category a binary image and
place the image in a picturebox, I can get the image to work if the
selection has only one image but the category may have more than one
image, usually when I put the datarow in a foreach statement it will
show all of the  images  and I can't get it to stay on the first image
then the user would push next button and the other images would appear
so on, I tried it also one image at a time, here is my code.
3.public void picCombo()
4.        {
5.
6.            string instrPic = comboBox1.SelectedItem.ToString();
7.            SqlConnection roy1 = new
SqlConnection(@"server=CAPTSISKO-PC\SQLEXPRESS;Initial
Catalog=cable;Integrated Security=True");
8.            roy1.Open();
9.            string newPic = "Select * from guidePic WHERE picTitle =
'" + instrPic + "'";
10.            ds = new DataSet();
11.            da = new SqlDataAdapter(newPic, roy1);
12.
13.            //_guidePic = BindingContext[da, "Pic"];
14.            da.Fill(ds, "newPic");
15.            comboBox1.DataBindings.Add("SelectedItem", ds,
"newPic");
16.     //       pictureBox1.DataBindings.Add("Image", ds, "newPic");
17.            bPic = this.BindingContext[ds, "newPic"];
18.            //foreach (DataRow dataRow in ds.Tables["newPic"].Rows)
19.          //  {
20.                Byte[] byteRoy = new Byte[0];
21.                  DataRow myRow;
22.                 myRow = ds.Tables["newPic"].Rows[0];
23.
24.
25.                 byteRoy = (byte[])myRow["Pic"];
26.                MemoryStream stimRoy = new MemoryStream(byteRoy);
27.
28.                // pictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage;
29.                int originalW = Image.FromStream(stimRoy).Width;
30.                int orignalH = Image.FromStream(stimRoy).Height;
31.                int resizedW = (int)(originalW * .370);
32.                int resizedH = (int)(orignalH * .370);
33.                Bitmap bmp = new Bitmap(resizedW, resizedH);
34.
35.                Graphics graphic = Graphics.FromImage((Image)bmp);
36.                graphic.DrawImage(Image.FromStream(stimRoy), 0, 0,
resizedW, resizedH);
37.                graphic.Dispose();
38.                bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
39.
40.                bmp.Save("RoyNew");
41.
42.                for (int j = 1; j < 100; j++)
43.                {
44.
45.
46.                    pictureBox1.Image = ((Image)bmp);
47.
48.                    pictureBox1.Refresh();
49.
50.
51.                }
52.
53.         //  }
54.
55. private void displyButt_Click(object sender, EventArgs e)
56.        {
57.            picCombo();
58.        }
59.
60.
61.        }
62.
63.The comment areas are for  going thru the counts but right now I am
just using a single , I have tried binding the picturebox but it is
not working, can anyone please help me with this, I have been working
on this for about two months and just don't seem to get it right.

Reply via email to