2
Answers

picture in picture object using path in crystal report

nafees khan

nafees khan

8y
292
1
public class studentlist
{
public string Photopath1 { get; set; }
}
var query = (from b in db.User_Students_Registration select new { b.Photopath});
if (query.Count() > 0)
{
foreach (var a in query)
{
Pictureobject p=(Pictureobject)cr.ReportDefinition.Sections ["Section3"]ReportObjects["rptStudentDetailstext1"];
p.Picture = a.Photopath;
}
}
//This Code is For Displaying Image From Database Using Path in Crystal Report. //But My image Not //Display in Picture object Please Help Me 
Answers (2)
0
Vulpes
NA 98.3k 1.5m 11y
The form's constructor runs before the form has loaded.

When the form loads, the Paint events for the form and its controls fire. Unfortunately, these events erase anything that has been drawn with a Graphics object derived from the CreateGraphics() method and so you don't see it.

Check this link for confirmation:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.creategraphics(v=vs.110).aspx

Incidentally, when you use CreateGraphics, you should always call Dispose() on the Graphics object to get rid of the underlying unmanaged resources. So I'd change your code to this:

        private void button1_Click(object sender, EventArgs e)
        {
            Rectangle r = new Rectangle(2, 2, 20, 10); //left,top,width,heigth
            Graphics g = pictureBox1.CreateGraphics();
            g.FillRectangle(Brushes.Red, r);
            g.Dispose();
        }
Accepted
0
Rob Sobol
NA 9 4.3k 11y


Works like a charm !

Problem solved !

WhooHoo !