ComboBoxにbooleanのDataSourceを設定

boolだからCheckBoxで良さそうだけど、どうしてもComboBoxがいいって言われる時があるんだよね。

BooleanComboBox.png

/// <summary>
/// Combobox に boolean の DataSource を設定。
/// </summary>
public static void SetBooleanDataSource(ComboBox comboBox, 
  string trueText = "あり", string falseText = "なし")
{
  var d = new Dictionary<bool, string>();
  d.Add(true, trueText);
  d.Add(false, falseText);

  comboBox.DataSource = null;
  comboBox.ValueMember = "Key";
  comboBox.DisplayMember = "Value";
  comboBox.DataSource = d.ToList();
}