自动填充文本框datagridview [英] autocomplete textbox datagridview
本文介绍了自动填充文本框datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这个代码除了datagridview之外还适用于我的文本框,而不是datagridview中的文本框?
我现在已经玩了近2个小时。一切都说这应该有用
Why does this code work for my textbox besides the datagridview, but not the textbox in the datagridview?
I have puzzeled and searced for almost 2 hours now. Everything says this should work
private void dgvFunn_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (this.dgvFunn.CurrentCell.ColumnIndex == this.dgvFunn.Columns["Virkestoff"].Index)
{
if (Snacks.acscVirkestoff == null)
{
Snacks.acscVirkestoffFyll();
}
tbAntKvartaler.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
tbAntKvartaler.AutoCompleteSource = AutoCompleteSource.CustomSource;
TextBox cbo = new TextBox();
cbo = (TextBox)e.Control;
cbo.AutoCompleteMode = AutoCompleteMode.Append;
cbo.AutoCompleteSource = AutoCompleteSource.CustomSource;
cbo.AutoCompleteCustomSource = Snacks.acscVirkestoff;
tbAntKvartaler.AutoCompleteCustomSource = Snacks.acscVirkestoff;
}
}
推荐答案
为什么要创建新的文本框只是为了在下一行重新分配它?
Why are you creating a new Textbox only to reassign it in the next line?
TextBox cbo = new TextBox();
cbo = (TextBox)e.Control;
TextBox cbo = (TextBox)e.Control;
我假设你已经调试并变化了e.Control是一个文本框。怎么了? 这不起作用不是非常具有描述性或有帮助。
I assume you have debugged and varified e.Control is a textbox. What is happening? "This doesn't work" isn't very descriptive or helpful.
仍有问题。这看起来很奇怪。
Still having problems with this. This seems very odd.
private void dgvFunn_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox te = e.Control as TextBox;
te.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
te.AutoCompleteCustomSource.AddRange(new string[] { "one", "two", "three" });
te.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
仍然无法为我工作,当我在任何列中打字母o时没有自动完成,它通过此代码运行,但在UI中没有任何操作
Still wont work for me, no autocomplete when i punch the letter o in any columns, it runs trough this code but does nothing in the UI
m ***** f *****。
最后我解决了这个问题。如果defaultcellstyle上的wrapmode设置为true,则无法使用上面的代码自动完成。设置wrapmode false是(愚蠢的)解决方案
这么多小时我用过这个!
m***** f*****.
Finally i solves this sh*t. If the wrapmode on the defaultcellstyle is set to true, you cannnot autocomplete with above code. Setting wrapmode false is the (stupid) solution
so many hours i have used on this!
这篇关于自动填充文本框datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文