<small id='BnRAx'></small><noframes id='BnRAx'>

    <tfoot id='BnRAx'></tfoot>
  1. <i id='BnRAx'><tr id='BnRAx'><dt id='BnRAx'><q id='BnRAx'><span id='BnRAx'><b id='BnRAx'><form id='BnRAx'><ins id='BnRAx'></ins><ul id='BnRAx'></ul><sub id='BnRAx'></sub></form><legend id='BnRAx'></legend><bdo id='BnRAx'><pre id='BnRAx'><center id='BnRAx'></center></pre></bdo></b><th id='BnRAx'></th></span></q></dt></tr></i><div id='BnRAx'><tfoot id='BnRAx'></tfoot><dl id='BnRAx'><fieldset id='BnRAx'></fieldset></dl></div>

    • <bdo id='BnRAx'></bdo><ul id='BnRAx'></ul>

    <legend id='BnRAx'><style id='BnRAx'><dir id='BnRAx'><q id='BnRAx'></q></dir></style></legend>

    1. 文本框自动完成无法正常工作

      时间:2023-06-08

      1. <legend id='lujfF'><style id='lujfF'><dir id='lujfF'><q id='lujfF'></q></dir></style></legend>
          <tfoot id='lujfF'></tfoot>

                <bdo id='lujfF'></bdo><ul id='lujfF'></ul>

                <small id='lujfF'></small><noframes id='lujfF'>

                <i id='lujfF'><tr id='lujfF'><dt id='lujfF'><q id='lujfF'><span id='lujfF'><b id='lujfF'><form id='lujfF'><ins id='lujfF'></ins><ul id='lujfF'></ul><sub id='lujfF'></sub></form><legend id='lujfF'></legend><bdo id='lujfF'><pre id='lujfF'><center id='lujfF'></center></pre></bdo></b><th id='lujfF'></th></span></q></dt></tr></i><div id='lujfF'><tfoot id='lujfF'></tfoot><dl id='lujfF'><fieldset id='lujfF'></fieldset></dl></div>
                  <tbody id='lujfF'></tbody>
                本文介绍了文本框自动完成无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用数组形式的自定义数据源实现文本框自动完成功能,该数组显示有关单字符输入的建议.但是当我运行程序时,自动完成仅在第二个字符输入后开始.当我调试时,我看到 AutoCompleteNameCollection 中有数据,但直到第二个字符输入才显示在建议中.

                I am trying to implement a textbox autocomplete with a custom datasource in the form of an array which shows suggestions on single character input. But when i run the program the autocomplete only starts after the second character input. When i debugged i saw that datas are there in the AutoCompleteNameCollection but it is not showing in the suggestion until the second character input.

                这段代码是我在 textchange 事件中写的.

                This code i have written in the textchange event.

                arr = LoadName(empid_txt.Text.Trim());  //arr is string array                          
                namesCollection.AddRange(arr);
                this.empid_txt.AutoCompleteMode = AutoCompleteMode.Suggest;
                this.empid_txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
                this.empid_txt.AutoCompleteCustomSource = namesCollection;
                

                在 LoadEvent 中,我使用空数组初始化了 AutoCompleteNameCollection.

                In the LoadEvent I have initialized the AutoCompleteNameCollection with an empty array.

                namesCollection.AddRange(arr);// here arr is empty
                empid_txt.AutoCompleteMode = AutoCompleteMode.Suggest;
                empid_txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
                empid_txt.AutoCompleteCustomSource = namesCollection;
                

                但在输入第二个字符之前它不起作用.但是,如果我使用空字符串而不是数组来初始化 AutoCompleteNameCollection,例如: namesCollection.Add("");它确实适用于单个字符输入,但有时它会给出 AccessViolationException: Attempted to read or write protected memory.那么有什么办法可以解决这个问题吗?

                But it does't work until the second character input. However if instead of an array i initialize the AutoCompleteNameCollection with an empty string like : namesCollection.Add(""); it does work for the single character input but some times it gives AccessViolationException: Attempted to read or write protected memory. So is there any way i can solve this problem?

                推荐答案

                在加载时,您可以使用数据的子集填充 TextBox(甚至可以缓存以供将来/共享使用).如果你有一个最常见"的计数器,你可以使用它.作为限制条件,您甚至可以添加一个 dummy 项目(如果您使用空字符串获得的是访问冲突).然后,在 TextChange 事件中从数据库中读取您需要的数据.

                On load you may populate the TextBox with a sub-set of your data (that can be even cached for future/shared use). If you have a "most common" counter you can use it. As limit condition you may even add a dummy item (if what you get with an empty string is an access violation). Then, on the TextChange event read the data you need from the database.

                我只有一个问题:您不想在用户开始输入之前填充源代码吗?如果存在网络流量问题,那么您会移动大量数据.如果您移动大量数据,那么您的用户在开始输入内容时将不得不等待.可以接受吗?另一方面,如果他们不等待太多,则数据流可能不是那么大,您可以将该逻辑放在表单构造函数中的 BackgroundWorker 中(或者离那个时间不远).

                I have only one question: you do not want to populate the source until the user starts to type? If there's the problem of network traffic then you move a lot of data. If you move a lot of data then your users will have to wait when they start to type something. Is it acceptable? On the other side if they do not wait too much maybe data stream is not so big and you can put that logic in a BackgroundWorker in the constructor of your form (or not far from that time).

                这篇关于文本框自动完成无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:检测何时显示 TextBox 自动完成列表 下一篇:Winforms:插入符号位置的屏幕位置

                相关文章

                1. <legend id='I7sgS'><style id='I7sgS'><dir id='I7sgS'><q id='I7sgS'></q></dir></style></legend>
                    • <bdo id='I7sgS'></bdo><ul id='I7sgS'></ul>
                    <i id='I7sgS'><tr id='I7sgS'><dt id='I7sgS'><q id='I7sgS'><span id='I7sgS'><b id='I7sgS'><form id='I7sgS'><ins id='I7sgS'></ins><ul id='I7sgS'></ul><sub id='I7sgS'></sub></form><legend id='I7sgS'></legend><bdo id='I7sgS'><pre id='I7sgS'><center id='I7sgS'></center></pre></bdo></b><th id='I7sgS'></th></span></q></dt></tr></i><div id='I7sgS'><tfoot id='I7sgS'></tfoot><dl id='I7sgS'><fieldset id='I7sgS'></fieldset></dl></div>
                  1. <tfoot id='I7sgS'></tfoot>

                    <small id='I7sgS'></small><noframes id='I7sgS'>