Solved

Display bmp in picture box in C#

Posted on 2013-05-19
5
603 Views
Last Modified: 2013-05-20
Hey guys!!

I have a C# application in which I would like to display a signature that is stored in a bmp file.
The signature is in \\CAKPOSSERVER\C\POSiTrack\Sigs.  The file name would be SIG_450566 or some other number matching a transaction number.  I would like to display this signature in a picture box on a form that is opened to show all the information from transaction number 450566 or some other transaction selected in a list or by keying 450566 in a text box and pressing enter.  This would display the transaction form along with the signature.

Thanks guys!!

Jerry
0
Comment
Question by:JDL129
  • 3
  • 2
5 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 39179388
Try something like...
        private void button1_Click(object sender, EventArgs e)
        {
            string folder = @"\\CAKPOSSERVER\C\POSiTrack\Sigs";
            string bmpName = "SIG_" + textBox1.Text + ".bmp";
            string FileName = System.IO.Path.Combine(folder, bmpName);
            if (System.IO.File.Exists(FileName))
            {
                try
                {
                    using (Image img = Image.FromFile(FileName))
                    {
                        pictureBox1.Image = new Bitmap(img);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("File: " + FileName + Environment.NewLine + ex.ToString(), "Error Opening Image");
                }
            }
            else
            {
                MessageBox.Show("File: " + FileName, "File Not Found");
            }
        }

Open in new window

0
 

Author Comment

by:JDL129
ID: 39179785
Idle_Mind!!!!

You're the MAN!!!

thanks,

Jerry
0
 

Author Closing Comment

by:JDL129
ID: 39179786
Excellent!!!
0
 

Author Comment

by:JDL129
ID: 39181809
Idle_Mind!!!

You are awsome!!  I think I should award you more points!!

Thanks again,
Jerry
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 39181830
Uh...no problem.  =)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question