Dropdown/select inside messagebox in winforms

Viewed 921

I would like to have a dropdown/select thing inside my msgbox in c#. Like this one

But to select color theme.

I have tried the following

string[] items = {"Black", "White", "Red", "Green", "Blue"};
string msg = "Select one color theme you like to have active", items;
string title = "Select color theme";
messagebox buttons = MessageBoxButtons.YesNo;
DialogResult result;
result = MessageBox.Show(msg, title, buttons);

But its not working. Do u know any solution to this?

2 Answers

MessageBox is a foraign class where you not can add additional controls. You have to build the Control by yourself.

var form = new Form(); // or control how you like
var dropDown = new ComboBox();
// some dropdown settings ....
string[] installs = new string[]{"Typical", "Compact", "Custom"};
dropDown .Items.AddRange(installs);
form.Controls.Add(dropDown)

// start/show the control
form.Show();

ComboBox Docu

The easiest way will be to create a custom form then use .ShowDialog()

Related