troubleshooting Question

Use Image from Resources for Background on Button in C#

Avatar of khyer123
khyer123 asked on
.NET ProgrammingC#
2 Comments1 Solution1231 ViewsLast Modified:
I have an application that dynamically creates buttons based on usernames in a database. I would like to be able to set the BackgroundImage to a picture that I have in my Resources folder, but I can't seem to be able to do that through code. For static buttons, I can click on the button and change the BackgroundImages to a picture I have in my Resources.resx file. I can't figure out how to code this. Any ideas?
Button b = new Button();
b.Text = str_user_names[i];
b.size = new Size(150, 75);
b.Click += new System.EventHandler(Onb2Click);
//want to specify b.BackgroundImage here
b.BackgroundImageLayout = ImageLayout.Stretch;
b.ForeColor = Color.WhiteSmoke;
flowLayoutPanel1.Control.Add(b);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros