在Winform中,我有一个TextBox。我将其设置为“ AutoComplete”,并且我想知道在我的代码(c#)中写什么,以将其“ AutoCompleteSource”设置为DataSet表中某些列的值。 谢谢!
答案 0 :(得分:1)
假设您在traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/7679791231c143f9/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/7679791231c143f9/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/7679791231c143f9/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/e~emailtest69/20190507t182648.418021119853034691/main.py", line 23, in <module>
from google.auth import app_engine
File "/base/data/home/apps/e~emailtest69/20190507t182648.418021119853034691/lib/google/auth/app_engine.py", line 29, in <module>
from google.auth import crypt
File "/base/data/home/apps/e~emailtest69/20190507t182648.418021119853034691/lib/google/auth/crypt/__init__.py", line 39, in <module>
from google.auth.crypt import rsa
File "/base/data/home/apps/e~emailtest69/20190507t182648.418021119853034691/lib/google/auth/crypt/rsa.py", line 27, in <module>
from google.auth.crypt import _python_rsa
File "/base/data/home/apps/e~emailtest69/20190507t182648.418021119853034691/lib/google/auth/crypt/_python_rsa.py", line 24, in <module>
from pyasn1.codec.der import decoder
ImportError: No module named pyasn1.codec.der
变量中有一个数据表,然后以自动完成源的形式显示其列的列表,则可以使用如下代码:
table
但是,使用var columns = table.Columns.Cast<DataColumn>();
var source = new AutoCompleteStringCollection();
source.AddRange(columns.Select(x => x.ColumnName).ToArray());
textBox1.AutoCompleteCustomSource = source;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
textBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
更有意义。要查看ComboBox
的示例,请查看this post。
答案 1 :(得分:0)
使用此信息填充数据源:
Source = dt.AsEnumerable().Select<System.Data.DataRow, String>(x => x.Field<String>("Name")).ToArray();
这将建议您
textbox.AutoCompleteCustomSource = source;
textbox.AutoCompleteMode = AutoCompleteMode.Suggest;
textbox.AutoCompleteSource = AutoCompleteSource.CustomSource;
答案 2 :(得分:0)
在代码中:
var rows = table.Rows.Cast<DataRow>();
var source = new AutoCompleteStringCollection();
source.AddRange(rows.Select(x => x.Field<String>("ColumnName")).ToArray());
textBox.AutoCompleteCustomSource = source;
textBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
textBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
只需替换table
,textBox
和"ColumnName"
。