Reputation: 3143
I have a Windows Forms form, and I want the user to select the background image. That is, when the application starts the file dialog appears from where the user can select the image he/she wants as the background.
How do I do this?
Upvotes: 1
Views: 593
Reputation: 1581
There is a file dialog class http://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.aspx which you can use to ask the user to select an image. Then you can set the forms BackgroundImage
property.
Upvotes: 2
Reputation: 2712
To expand on havok's answer, if you set WindowState = WindowState.Minimized
and ShowInTaskbar = false
during form initialization, you can display the dialog in a Form.Load
event handler ("occurs before a form is displayed for the first time"). The user will see the dialog before the main form is noticeable at all. After retrieving the image, set the BackgroundImage
property as havok said, and restore the form to a normal startup state. System.Drawing.Image
has a static method FromFile()
that might help you, too.
Upvotes: 3