本文介绍了如何在作为组合框的gridview单元格中维护一个值并设置为自动完成?我有一个gridview和一个自动完成的组合框列,它可以正常工作,但是当我选择一个值并且......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 {private void dataGridViewX1_EditingControlShowing(object sender,DataGridViewEditingControlShowingEventArgs e) { if(e.Control is DataGridViewComboBoxEditingControl) { AutoCompleteStringCollection strng = new AutoCompleteStringCollection(); SqlDataReader reader; con.Open(); SqlCommand cmd = new SqlCommand(select * from Item_tbl,con); cmd.CommandType = CommandType.Text; reader = cmd.ExecuteReader (); if(reader.HasRows == true) { while(reader.Read()) { strng.Add(reader [Name]。ToString()); ((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropDown ; ((ComboBox)e.Control).AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; ((ComboBox)e.Control).AutoCompleteSource = AutoCompleteSource。 CustomSource; ((ComboBox)e.Control).AutoCompleteCustomSource = strng; } } } con.Close(); } } {private void dataGridViewX1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control is DataGridViewComboBoxEditingControl) { AutoCompleteStringCollection strng = new AutoCompleteStringCollection(); SqlDataReader reader; con.Open(); SqlCommand cmd = new SqlCommand("select * from Item_tbl ", con); cmd.CommandType = CommandType.Text; reader = cmd.ExecuteReader(); if (reader.HasRows == true) { while (reader.Read()) { strng.Add(reader["Name"].ToString()); ((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropDown; ((ComboBox)e.Control).AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; ((ComboBox)e.Control).AutoCompleteSource = AutoCompleteSource.CustomSource; ((ComboBox)e.Control).AutoCompleteCustomSource = strng; } } } con.Close(); }}推荐答案 这篇关于如何在作为组合框的gridview单元格中维护一个值并设置为自动完成?我有一个gridview和一个自动完成的组合框列,它可以正常工作,但是当我选择一个值并且......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 17:41