Sapna
How to display an image from listbox in WPF?
Posted by Sapna in .NET 4.5 on Nov 13, 2010
  • 0
  • 4
  • 6981
Do you know the answer for this question? Post it below.
Guest
Posted by Purushottam Rathore on Jan 31, 2011
  • 0

Hi sapna



This click here to resolve your problem.



http://www.c-sharpcorner.com/UploadFile/mahesh/WPFListBox07312008002559AM/WPFListBox.aspx



 



Thanks

Posted by sumit bakshi on Nov 24, 2010
  • 0

yes you can do this you can bind listbox based on the datakey name and display image in image controle based on listbox selected value

Posted by Ashish Shukla on Nov 16, 2010
  • 0

Write the following in the onSelectedIndexchanged event of listbox
  SqlConnection con=new SqlConnection();
            //set the connection string below
            con.ConnectionString = "";
            //set the ID in the below code to the name in the listbox instead of hardcoded value
            SqlCommand cmdSelect = new SqlCommand("select Picture" +
              " from TableName where ID=@ID",con);
            cmdSelect.Parameters.Add("@ID",SqlDbType.Int, 4);
            //set the id below
            cmdSelect.Parameters["@ID"].Value = "2";



            con.Open();
            byte[] barrImg = (byte[])cmdSelect.ExecuteScalar();
            string strfn = Convert.ToString(DateTime.Now.ToFileTime());
            FileStream fs = new FileStream(strfn,
                              FileMode.CreateNew, FileAccess.Write);
            fs.Write(barrImg, 0, barrImg.Length);
            fs.Flush();
            fs.Close();
           
            Image1.Image =System.Drawing.Image.FromFile(strfn);

Posted by Sapna on Nov 13, 2010
  • 0

Hi,
Anybody help me to solve this problem. Suppose I have a list box with different types of dishes with their images but in the listbox only their names to be shown. Then if i select a dish from the listbox its image should be display outside the listbox.



Thanx


Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS

PRIVACY POLICY | TERMS & CONDITIONS | SITEMAP | CONTACT US | ABOUT US | REPORT ABUSE
2014© C# Corner. All contents are copyright of their authors.