目次: C# - Windows Formsでよく使うコントロールたち (Visual Studioなし環境向け) - Qiita
画面キャプチャ
テンプレ
using System;
using System.Drawing;
using System.Windows.Forms;
class ComboBoxSample : Form
{
ComboBox cmb;
ComboBoxSample()
{
ClientSize = new Size(300, 100);
Controls.Add(cmb = new ComboBox(){
Location = new Point(0, 0),
Width = 80,
DropDownStyle = ComboBoxStyle.DropDownList, // 直接編集不可設定
FormattingEnabled = true, // 頂いたコメントを受けて追加しました!
});
cmb.Items.AddRange(new string[]{"未選択","出勤","直行","不帰","不在"});
cmb.SelectedIndex = 0;
cmb.TextChanged += Cmb_TextChanged;
}
void Cmb_TextChanged(object sender, EventArgs e)
{
Text = cmb.Text;
}
[STAThread]
static void Main()
{
Application.Run(new ComboBoxSample());
}
}