我在表单加载中将 ReadOnly 属性写为 true
dgvDcNon.Columns["itemDiscrip"].ReadOnly = true;
但该属性不工作。我应该采取更多步骤来实现这一点吗?
我在editingcontrolshowing事件中将自动完成模式设置为datagridview。有什么原因吗?我的代码是
if (e.Control is TextBox)
{
TextBox tbValid = e.Control as TextBox;
tbValid.KeyPress += new KeyPressEventHandler(tbValid_KeyPress);
}
String[] strAutoCmp = prodctsDCCls.AutoCmpltPrdct();
TextBox txtAuto = e.Control as TextBox;
txtAuto.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txtAuto.AutoCompleteSource = AutoCompleteSource.CustomSource;
if (this.dgvDcNon.Columns[this.dgvDcNon.CurrentCell.ColumnIndex].Name == "itemDiscrip")
{
var name = new AutoCompleteStringCollection();
name.AddRange(strAutoCmp);
if (txtAuto != null)
{
txtAuto.AutoCompleteCustomSource = name;
}
}
else
{
txtAuto.AutoCompleteCustomSource = null;
}