[英]items not appearing in ComboBox list C#
我想要下拉列表中的预定用户名,用户可以使用组合框从中进行选择。下面的代码不起作用。 登录图片
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox1.Items.Add("Attendee");
comboBox1.Items.Add("HOD");
comboBox1.Items.Add("Driver");
comboBox1.Items.Add("FD");
}
}
}
双击您的登录表单,然后将代码Load
事件处理程序中。 默认情况下,事件处理程序名称为YourFormName_Load
。
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("Attendee");
comboBox1.Items.Add("HOD");
comboBox1.Items.Add("Driver");
comboBox1.Items.Add("FD");
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.