I have a datagridviewcell with textbox as the control hosted by it. Now how do I get the type of control programmatically in other parts of my code?
I add the column like this:
DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
col.ReadOnly = false;
col.Name = "Status";
col.HeaderText = "Status";
dgv.Columns.Add(col);
All the cells in that column now will have a textbox. I can get the control as a textbox like this:
private void dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dgv.CurrentCell.ColumnIndex == 5 && e.Control is TextBox)
{
//something
}
}
How do I get the type of control hosted in the cell elsewhere? How to get e.Control
from other parts of code so that I can do things like:
((TextBox)dgv[i, j].EditinControl).AutoCompleteSource = AutoCompleteSource.CustomSource;
((TextBox)dgv[i, j].EditinControl).AutoCompleteCustomSource = someSource;
((TextBox)dgv[i, j].EditinControl).AutoCompleteMode = AutoCompleteMode.SuggestAppend;
etc. What can substitute for EditinControl
in the above line.. ??