Thursday 15 March 2012

winforms - Prevent Paste strings into Combo Box which are not items of that Combo Box in C# -


I am using the C # win form and I need to stop the paste in a combo box in it. Drop-down item not in list) If the paste string is an item in the drop down list, then it should be allowed to paste. I already prevent the user attempts to enter non existing items. Code below the code

  Private zero list location_imppress (object sender, key press event Eg) {if (Char.IsControl (e.KeyChar)) {return; } Combo box box = ((combo box) sender); String non-selected = box Lesson Inclination (0, box. Text. Length - box. Local selection); String text = non-selected + e. Keker; Bull Match = False; (Int i = 0; i & lt; box.Items.Count; i ++) {if (((DataRowView) box.Items [i]) [box. Displaymember] .restring (.) Start (text, True, zero)) {matching = true; break; }} E.Handled =! Matched; }    

try it ...

  private Zero comboBox1_TextChanged (object sender, EventArgs E) {// whenever the text changes occur (combobox1.findstringexact (comboBox1.Text)> gt; -1) {// if the code is not in the list}}  < / Pre>  

No comments:

Post a Comment