Windows应用程序中的文本框自动完成 [英] Textbox autocomplete in windows application

查看:111
本文介绍了Windows应用程序中的文本框自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在windows应用程序中使用vb.net。当我单击单选按钮时,我需要将用户名从数据库绑定到文本框自动完成。



在表单加载事件自动完成工作正常但单击单选按钮后甚至无法正常工作。



任意一个人可以帮助我



Hi,

I am using vb.net in windows application. I need to bind user name from database into text box autocomplete, when I click radio button.

In Form Load event autocomplete working fine but after radio button click even its not working.

Any one can able to help me

Public Sub getData(ByVal dataCollection As AutoCompleteStringCollection)
        ds = New Dataset()
        Dim sql As String = "SELECT DISTINCT [MAC] FROM [Customer]"
        Try
            con.Open()
            com = New OleDbCommand(sql, con)
            adap.SelectCommand = com
            adap.Fill(ds, "Macnumber")
            adap.Dispose()
            com.Dispose()
            con.Close()
            For Each row As DataRow In ds.Tables("Macnumber").Rows
                dataCollection.Add(row(0).ToString())
            Next
        Catch ex As Exception
            MessageBox.Show("Can not open connection ! ")
        End Try
    End Sub



以下编码我在Radio Button Checked Changed中添加了事件。

如果我在表单加载事件中包含该代码它没有更改事件它工作正常。



但是我想要单选按钮点击事件。因为同一个文本框我想绑定用户名和mac号码如果我点击用户名单选按钮用户名需要自动完成。如果我点击mac号mac号需要在同一文本框中建议。这就是为什么我准备打电话给这个在单选按钮点击事件中进行编码。





txtmacno.AutoCompleteMode = AutoCompleteMode.Suggest

txtmacno.AutoCompleteSource = AutoCompleteSource.CustomSource

Dim DataCollection As New AutoCompleteStringCollection()

getData(DataCollection)

txtmacno.AutoC ompleteCustomSource = DataCollection





谢谢你



Bala


The below coding I was added in Radio Button Checked Changed event.
Instead of changed event if I was included that code in form load event it was working fine.

But I want radio button click event. Because same text box i like to bind user name and mac number if I clicked user name radio button username need to autocomplete. If I clicked mac number mac number need to suggest in same text box. That's why i prepare to call this below coding in radio button click event.


txtmacno.AutoCompleteMode = AutoCompleteMode.Suggest
txtmacno.AutoCompleteSource = AutoCompleteSource.CustomSource
Dim DataCollection As New AutoCompleteStringCollection()
getData(DataCollection)
txtmacno.AutoCompleteCustomSource = DataCollection


Thanks you

Bala

推荐答案

首先添加您的解决方案然后我可以尝试找到解决方案
Add your solution first then i can try to find the solution


这篇关于Windows应用程序中的文本框自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆