我想在我的msgbox里面有一个dropdownselect的东西,在c#中。像这个
但要选择颜色主题。
我试过以下方法
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);
但它不工作。Do u know any solution to this?
MessageBox是一个不能添加额外控件的类,你必须自己建立一个控件。你必须自己构建控件。
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();
最简单的方法是创建一个自定义表单,然后使用.ShowDialog()