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.?
Using Height property you can set the height of the button. Using Image property you can set the image on the button.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With