免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
方法腳本2:組合框comboBox和listbox配合模糊查詢顯示
 Private Sub CoBox1_TextChanged(sender As Object, e As EventArgs) Handles CoBox1.TextChanged
        '獲取輸入的字符串
        Dim text As String = CoBox1.Text.Trim()
        '用以記錄匹配字符串的個數(shù)
        Dim index As Integer = 0
        Dim listBox1 As New ListBox
        ' list_Pd是定義的全局布爾變量,用于判斷是否創(chuàng)建了listbox控件
        If list_pd Then '如果已經(jīng)創(chuàng)建
            For Each contr As Control In Me.Controls '遍歷窗體中的所有控件,尋找創(chuàng)建的listbox控件
                If contr.Name = "list" Then
                    listBox1 = CType(contr, ListBox)
                End If
            Next
        Else '如果沒有創(chuàng)建,則調(diào)用Custom_ListBox()函數(shù)創(chuàng)建
            listBox1 = Custom_ListBox(CoBox1)
        End If
        '將listbox 控件所有項清空
        listBox1.Items.Clear()
        '將查詢的結(jié)果添加到listbox 的items 中
        For Each Str As String In CoBox1.Items
            '將所有的字符串全部轉(zhuǎn)化為小寫再判斷,這樣輸入就不用分大小寫了
            If Not text = "" And Str.ToLower.Contains(text.ToLower) Then
                index += 1
                listBox1.Items.Add(Str)
            End If
        Next
        '判斷符合條件的項的個數(shù),
        If index = 1 Then
            CoBox1.Text = listBox1.Items(0)
            listBox1.Visible = False
        ElseIf index > 1 Then
            listBox1.Visible = True
        Else
            listBox1.Visible = False
        End If
        listBox1.BringToFront()
    End Sub
    Private Function Custom_ListBox(ByVal CoBox1 As ComboBox) As ListBox
        Dim Listbox As New ListBox
        Dim point As Point
        point.X = CoBox1.Location.X
        point.Y = CoBox1.Location.Y + CoBox1.Height
        With Listbox
            .Name = "list" '設(shè)置控件名稱
            .Location = point  '設(shè)置控件的位置,放在combobox的下面
            .Width = CoBox1.Width '控件的寬度,與combobox的寬一樣
            .Height = CoBox1.Height * (CoBox1.Items.Count + 1) '高度

            .Items.Clear()
            .Visible = False
        End With
        AddHandler Listbox.Click, AddressOf ListBox_Click '添加點擊事件 ListBox_Click()
        Me.Controls.Add(Listbox) '這步重要 將控件添加到窗體中。沒有這句將不會顯示listbox控件
        list_pd = True
        Return Listbox
    End Function
    Private Sub ListBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        CType(sender, ListBox).Visible = False
        CoBox1.Text = CType(sender, ListBox).SelectedItem
    End Sub
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
一步步教你做簡單的進(jìn)銷存系統(tǒng)(2:控件事件)
輸入時逐步提示信息
vb.net入門——ComboBox 控件的使用
在VB中創(chuàng)建word文檔?
CSDN 論壇
《Visual Basic 2005 程序設(shè)計》第5章 數(shù)據(jù)結(jié)構(gòu)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服