本文介绍了C#Winform中的自动完成文本框速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在我的项目中,我使用的是自动填充文本框。我在自动填充文本框中绑定电话号码与数据库。我的桌子上有超过500条记录(电话没有表格)。它在我的方法中加载非常慢。如何提高自动完成的性能。如果有人知道这个PLZ的解决方案就回复我...



谢谢&问候

OleDbCommand cmd1 = null ; OleDbCommand cmd11 = null ;
namesCollection1.Clear();
cmd1 = new OleDbCommand( select *来自InvoiceDetails,Con);
OleDbDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
if (!namesCollection1.Contains(dr1 [ 4 ]。ToString()))
{
namesCollection1.Add(dr1 [ 4 ]的ToString());
}
}
cmd1.Dispose();
dr1.Dispose();


cmd11 = new OleDbCommand( select * from CustomerDetails,Con);
OleDbDataReader dr11 = cmd11.ExecuteReader();
while (dr11.Read())
{
if (!namesCollection1.Contains(dr11 [ 11 ]。ToString()))
{
namesCollection1.Add(dr11 [ 11 ]的ToString());
}
}
cmd11.Dispose();
dr11.Dispose();

PhoneNoText.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
PhoneNoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
PhoneNoText.AutoCompleteCustomSource = namesCollection1;







添加OP发布的代码块作为评论 - Original Griff [ / edit]

解决方案

Hi Everyone,

In my project i m using autocomplete textbox. i m binding the Phone no from database in autocomplete textbox. I have more than 500 records in my table (phone no table). it loading very slow in my method. how can i increase performance for autocomplete. if any one know solution for this plz just reply me...

thanks & regards

OleDbCommand cmd1 = null; OleDbCommand cmd11 = null;
namesCollection1.Clear();
cmd1 = new OleDbCommand("select * from InvoiceDetails", Con);
OleDbDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
    if (!namesCollection1.Contains(dr1[4].ToString()))
    {
        namesCollection1.Add(dr1[4].ToString());
    }
}
cmd1.Dispose();
dr1.Dispose();


cmd11 = new OleDbCommand("select * from CustomerDetails", Con);
OleDbDataReader dr11 = cmd11.ExecuteReader();
while (dr11.Read())
{
    if (!namesCollection1.Contains(dr11[11].ToString()))
    {
        namesCollection1.Add(dr11[11].ToString());
    }
}
cmd11.Dispose();
dr11.Dispose();

PhoneNoText.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
PhoneNoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
PhoneNoText.AutoCompleteCustomSource = namesCollection1;




[edit]Added code block posted by OP as comment - Original Griff[/edit]

解决方案


这篇关于C#Winform中的自动完成文本框速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 13:25