Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the name of button background Image in Winforms C#

I added image to the resource in Form and set it as background Image for a button. How to get the name of the button's background image by through programmatic.?

like image 704
Arunkumar Chandrasekaran Avatar asked Feb 08 '12 11:02

Arunkumar Chandrasekaran


People also ask

Which property is used to display image on the button in C#?

Using Height property you can set the height of the button. Using Image property you can set the image on the button.

How do I change my winform name?

Initially the form is named as Form1. But for programing prospective or best practice, it should be meaning full. So to rename the select the form and right click on it and go to properties. Here under Font there is property called “Text” by changing it we can change the Title of the window.

How do I display an image in Winforms?

Open the Visual Designer of the form containing the control to change. Select the control. In the Properties pane, select the Image or BackgroundImage property of the control. Select the ellipsis ( ) to display the Select Resource dialog box and then select the image you want to display.

How do you display a graphic as the background of a Windows Form object?

Use the BackgroundImage Property to display a graphic as the background of a Windows Form object. Click on None to reveal a button with … to get the option to change the background click on the … and in the new window select Local Resource and click Import to browse for your picture to use.


1 Answers

You cannot retrieve the name of the image.

What you can do is when you set the image: store the name of the image in the Tag property of the Button.

You can then check the Tag property as long as you keep it in sync with the image.

Even nicer would be to sub-class the Button and add a property that stores the name.

like image 93
Emond Avatar answered Sep 29 '22 21:09

Emond