我有一个 Process 类型的对象数组,我想在组合框中显示这个列表,按字母顺序排列并且全部大写。
Process 对象属性“ProcessName”是“DisplayMember”;它是一个只读属性。
private void Form1_Load(object sender, EventArgs e)
{
//get the running processes
Process[] procs = Process.GetProcesses();
//alphabetize the list.
var orderedprocs = from p in procs orderby p.ProcessName select p;
//set the datasource to the alphabetized list
comboBox1.DataSource = orderedprocs.ToArray<Process>();
comboBox1.DisplayMember = "ProcessName";
// Make the display member render as UPPER CASE???
//comboBox1.FormatString
}
我怀疑答案在于 FormatString