我是 C# 和 GUI 编程的新手,所以我觉得这很简单,但是 DisplayMember 上的文档让我感到困惑。
List<string[]> serverInfo = new List<string[]>();
serverInfo.Add(new string[] { "server one", "1.2.3.4", "12345" });
serverInfo.Add(new string[] { "server two", "1.2.3.4", "12346" });
serverInfo.Add(new string[] { "server three", "1.2.3.5", "12343" });
ComboBox serverPickList = new ComboBox();
serverPickList.DataSource = serverInfo;
serverPickList.DisplayMember = "???";
ComboBox 的选项应该是“服务器一”、“服务器二”和“服务器三”,但我仍然希望绑定字符串 [] 数组,因为我将处理它们。