<P>Hi sapna</P> <P>This click here to resolve your problem.</P> <P><A href="/UploadFile/mahesh/WPFListBox07312008002559AM/WPFListBox.aspx">http://www.c-sharpcorner.com/UploadFile/mahesh/WPFListBox07312008002559AM/WPFListBox.aspx</A></P> <P> </P> <P>Thanks</P>
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<br>
<P>Write the following in the onSelectedIndexchanged event of listbox<BR> SqlConnection con=new SqlConnection();<BR> //set the connection string below<BR> con.ConnectionString = ""; <BR> //set the ID in the below code to the name in the listbox instead of hardcoded value<BR> SqlCommand cmdSelect = new SqlCommand("select Picture" +<BR> " from TableName where <A href='mailto:ID=@ID",con'>ID=@ID",con</A>);<BR> cmdSelect.Parameters.Add("@ID",SqlDbType.Int, 4);<BR> //set the id below<BR> cmdSelect.Parameters["@ID"].Value = "2";</P> <P> con.Open();<BR> byte[] barrImg = (byte[])cmdSelect.ExecuteScalar();<BR> string strfn = Convert.ToString(DateTime.Now.ToFileTime());<BR> FileStream fs = new FileStream(strfn,<BR> FileMode.CreateNew, FileAccess.Write);<BR> fs.Write(barrImg, 0, barrImg.Length);<BR> fs.Flush();<BR> fs.Close();<BR> <BR> Image1.Image =System.Drawing.Image.FromFile(strfn); </P>
<P><FONT size=2 face=Verdana>Hi,<BR>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.</FONT></P> <P><FONT size=2 face=Verdana>Thanx</FONT></P>
Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.