简体   繁体   中英

C# Modeless Dialog: How to return 3 different values from modeless dialog to main form and put them together to use as Color.FromARGB?

I have this code that I am working on and I need to return 3 values from a single modeless dialog so I can use it as Color.FromARGB. How is possible to do that?

Basically, what you want to do is to have this color dialog expose all the properties you want to make available to other dialogs/processes. In your case, you could just expose the values for red, green and blue as integer representations of three trackbars or textboxes or numeric updowns... it doesn't really matter the control you use, as long as you can expose their values through public properties.

Then, wire the changes of the trackbars (or textboxes) to an event which can be captured by the calling form and then have the calling form query the three properties and build a color using the Color.FromArgb method.

Here's a very simple example .

Note that there are many ways in which you can share data between forms. This is just one of them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM