DropDownStyleのComboBoxを使う場合、ComboBoxのLostFocusイベントに以下のロジックを加えておくと、ユーザーがリストに存在しない値を入力する事が無くなるので便利。
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  | 
						        private void ComboBoxLostFocus(object sender, EventArgs e)         {             if (((ComboBox)sender).Text.Length > 0)             {                 if (((ComboBox)sender).FindStringExact(((ComboBox)sender).Text) < 0)                 {                     MessageBox.Show("入力した値は、リストにありません。", "コンボボックス"                      , MessageBoxButtons.OK, MessageBoxIcon.Error);                     ((ComboBox)sender).Focus();                 }             }         }  | 
					
  
  
  
  

コメント