i just create a custom control, i want this control implement to datagridview's column.
but how? is it possible?
for example, i want add my column type like "DataGridViewCustomTextBoxColumn"
this is my current code.
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
Connection.ConnectionClose();
Connection.ConnectionOpen();
var source = new List<string>();
string queryItem = "SELECT * FROM ITEM ";
Connection.command = new OleDbCommand(queryItem, Connection.conn);
Connection.command.CommandType = CommandType.Text;
AutoCompleteStringCollection kode = new AutoCompleteStringCollection();
reader = Connection.command.ExecuteReader();
if (reader.HasRows == true)
{
while (reader.Read())
{
//kode.Add(reader["code"].ToString());
source.Add(reader["code"].ToString());
}
}
else
{
MessageBox.Show("Data not Found");
}
reader.Close();
//ComboBox txtBusID = e.Control as ComboBox;
TextBox kodeTxt = e.Control as TextBox;
if (kodeTxt != null)
{
kodeTxt.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
kodeTxt.AutoCompleteCustomSource = kode;
kodeTxt.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
}
}
what i tried.. like this.
AutoCompleteTextBoxSample.AutoCompleteTextbox kodeTxt = e.Control as AutoCompleteTextBoxSample.AutoCompleteTextbox;
if (kodeTxt != null)
{
kodeTxt.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
kodeTxt.AutoCompleteCustomSource = source;
kodeTxt.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
then my autocomplete is not working anymore
What i want is just like this.
I would use Template Fields for this as described here: https://msdn.microsoft.com/en-us/library/bb288032.aspx
One of the Template Fields will be your custom control.
This will involve writing code, rather than using the GUI.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.