Passing Image data between forms
-
Could someone pse tell me how I may pass the following between forms: I have a form with about 50 buttons and each opens a new form displaying a jpg picture (imported into Resources) in a PictureBox. When I close the form I'm back on the original form with the many buttons. It works pretty well but I think having just one extra form is more elegant - and less work! I need to pass Image data like MyProject.Properties.Resources._142 (the pic is 142.jpg) to the form and then open it. Somewhere I saw that one can use Form dispForm = new dispForm(yProject.Properties.Resources._142) but the method does not accept a parameter. I'm starting to like this language :) Many thanks for any help. Hannes
-
Could someone pse tell me how I may pass the following between forms: I have a form with about 50 buttons and each opens a new form displaying a jpg picture (imported into Resources) in a PictureBox. When I close the form I'm back on the original form with the many buttons. It works pretty well but I think having just one extra form is more elegant - and less work! I need to pass Image data like MyProject.Properties.Resources._142 (the pic is 142.jpg) to the form and then open it. Somewhere I saw that one can use Form dispForm = new dispForm(yProject.Properties.Resources._142) but the method does not accept a parameter. I'm starting to like this language :) Many thanks for any help. Hannes
hbez wrote:
Could someone pse tell me how I may pass the following between forms: I have a form with about 50 buttons and each opens a new form displaying a jpg picture (imported into Resources) in a PictureBox. When I close the form I'm back on the original form with the many buttons. It works pretty well but I think having just one extra form is more elegant - and less work! I need to pass Image data like MyProject.Properties.Resources._142 (the pic is 142.jpg) to the form and then open it. Somewhere I saw that one can use Form dispForm = new dispForm(yProject.Properties.Resources._142) but the method does not accept a parameter.
You can change the constructor in the form to accept the parameter. By default it's created without one, but there's no requirement that you have to leave it that way. Alternatively, you could expose a property on the form that accepted the appropriate value and set it before calling Show().
Deja View - the feeling that you've seen this post before.
-
Could someone pse tell me how I may pass the following between forms: I have a form with about 50 buttons and each opens a new form displaying a jpg picture (imported into Resources) in a PictureBox. When I close the form I'm back on the original form with the many buttons. It works pretty well but I think having just one extra form is more elegant - and less work! I need to pass Image data like MyProject.Properties.Resources._142 (the pic is 142.jpg) to the form and then open it. Somewhere I saw that one can use Form dispForm = new dispForm(yProject.Properties.Resources._142) but the method does not accept a parameter. I'm starting to like this language :) Many thanks for any help. Hannes
hbez wrote:
but the method does not accept a parameter.
You need to write the method that takes the parameter. Or you can create the image as a property that is lazy initialised on a static class, making it load the first time it's accessed, and accessible from your entire project.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )