looking for some solutions? You are welcome.

SOLVED: Listview image list from database

SherifClement:

i want to bind a image list from database i am getting the image name but image not coming is any body can help me

https://my.pcloud.com/publink/show?code=XZVs9q7ZQeWB0GN02mFHjLflE9oq5btE83mX

the above link is my output but i want to get the image also

public void ListimageGalery() {

       ImageList myimagelistsmall = new ImageList();
       ImageList myimageListLarge = new ImageList();
       ImageList myimagelist = new ImageList();

       ListImage.SmallImageList = myimagelistsmall;
       ListImage.LargeImageList = myimageListLarge;

       myimagelist.ImageSize = new Size(50, 50);
       myimagelistsmall.ImageSize = new Size(32, 32);
       myimageListLarge.ImageSize = new Size(80, 80);
       try
       {
           con = new SqlConnection(connectionpath);
           SqlDataAdapter dataAdapter = new SqlDataAdapter(new SqlCommand("SELECT StockItemImage,STKDESCP FROM Tbl_STKMaster", con));
           DataSet dataSet = new DataSet();
           dataAdapter.Fill(dataSet);

           ListImage.Items.Clear();
           myimageListLarge.Images.Clear();
           myimagelistsmall.Images.Clear();
          foreach(DataRow dr in dataSet.Tables[0].Rows)
           {
               try
               {
                   Byte[] data = new Byte[0];
                   data = (Byte[])(dataSet.Tables[0].Rows[0]["StockItemImage"]);
                   MemoryStream mem = new MemoryStream(data);
                   myimagelist.Images.Add(Image.FromStream(mem));
                   myimagelistsmall.Images.Add(Image.FromStream(mem));
                   myimageListLarge.Images.Add(Image.FromStream(mem));


               }
               catch (Exception ex) { MessageBox.Show(ex.Message); }
               ListImage.LargeImageList = myimageListLarge;
               ListImage.Items.Add(dataSet.Tables[0].Rows[0]["STKDESCP"].ToString());
               ListImage.View = View.LargeIcon;
               //ListImage.SmallImageList = myimagelist;
               //ListImage.Items.Add(dataSet.Tables[0].Rows[0]["STKDESCP"].ToString());
           }



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent