Click here to Skip to main content
11,703,632 members (68,633 online)
Rate this: bad
good
Please Sign up or sign in to vote.
Hi everyone,
How can i display sql image in tooltip when mouseover datagrid.I have this code that do not work.

<DataGridTemplateColumn Header="Image" Width="45" >
                   <DataGridTemplateColumn.CellTemplate>
                       <DataTemplate >
                           <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Padding="2">
                               <Image Source="{Binding Path=Picture}" Width="120" Height="50">
                                   <Image.ToolTip>
                                       <ToolTip DataContext="{Binding Path=Picture, ElementName=grdPersonnel1}" BorderBrush="LightBlue">
                                       </ToolTip>
                                   </Image.ToolTip>
                               </Image>
                           </Border>
                       </DataTemplate>
                   </DataGridTemplateColumn.CellTemplate>
Posted 2-Jul-12 4:34am
Comments
Kiran Susarla at 2-Jul-12 13:00pm
   
Can you please elaborate more on the problem you are facing. Are you getting any error?
biswarup88 at 3-Jul-12 2:51am
   
good question 5 from me.
govardhan4u at 3-Jul-12 11:31am
   
get the code written to display the image
Wes Aday at 3-Jul-12 11:43am
   
What is "sql image" and what does "do not work" mean?
SASS_Shooter at 3-Jul-12 12:19pm
   
If I understand your question then what you are asking is this:

You have an image in your program.
You want the image shown in a Tooltip.
You want that shown when you mouse over an entry in the datagrid.


You are displaying a very small snippet of what looks like XAML to me. Is this a WPF application, a Silverlight application, or just a web page?
Arian Shojaei at 4-Jul-12 13:07pm
   
this is a wpf application. I saved a picture in sql databse, and i can retrieve and see it in datagrid but i want to do mouse over on picture, tooltip display it more larger (zoom).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I saved a picture in sql databse, and i can retrieve and see it in datagrid but i want to do mouse over on picture, tooltip display it more larger (zoom).
This code block has this message in tooltip:Byte[] Array.

<DataGridTemplateColumn Header="Image" Width="45" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate >
                            <Image Source="{Binding Path=Picture}" Width="100" Height="50" Stretch="Uniform"  ToolTip="{Binding Path=Picture}">                           
                            </Image>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

Add new record event:
private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.* ";
 
                dlg.ShowDialog();
 
                FileStream fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read);
                byte[] data = new byte[fs.Length];
 
                fs.Read(data, 0, System.Convert.ToInt32(fs.Length));
                fs.Close();
 
                System.IO.Stream stream = System.IO.File.Open(dlg.FileName, System.IO.FileMode.Open);
 
                BitmapImage imgsrc = new BitmapImage();
                imgsrc.BeginInit();
                imgsrc.StreamSource = stream;
                imgsrc.EndInit();
                this.Picture.Source = imgsrc;
 
                SqlConnection con = new SqlConnection();
                con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\programing\WPF\DataBase.mdf;Integrated Security=True;User Instance=True";
                con.Open();
 
                SqlCommand sc = new SqlCommand("Insert Into Personnels(No,Name,Family,Picture) Values(@No,@Name,@Family,@Tozihat,@Picture)", con);
 
                sc.Parameters.AddWithValue("@No", txtNo.Text);
                sc.Parameters.AddWithValue("@Name", txtName.Text);
                sc.Parameters.AddWithValue("@Family", txtFamily.Text);
                sc.Parameters.AddWithValue("@Picture", data);
 
                sc.ExecuteNonQuery();
                con.Close();
 
}
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I hope this will help you.

<![CDATA[<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default6.aspx.vb" Inherits="Default6" %>]]>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 570
1 OriginalGriff 500
2 Sergey Alexandrovich Kryukov 410
3 F-ES Sitecore 165
4 Andy Lanng 159
0 OriginalGriff 8,519
1 Sergey Alexandrovich Kryukov 7,667
2 CPallini 4,987
3 Maciej Los 4,686
4 Mika Wendelius 3,566


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 4 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100