日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

100% .NET Control_自动完成Combobox的XComBo控件(VB.NET)

發(fā)布時(shí)間:2025/3/15 asp.net 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 100% .NET Control_自动完成Combobox的XComBo控件(VB.NET) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

其實(shí)這類的文章在國外的技術(shù)網(wǎng)站上也有很多,但是都沒有實(shí)現(xiàn)combobox的自動(dòng)下拉.
在這里實(shí)現(xiàn)了自動(dòng)下拉.
在這里我把combobox做成了一個(gè)控件(XComBo)來實(shí)現(xiàn)功能.它從ComboBox,可以將新建的
工程的繼承改為? Inherits System.Windows.Forms.ComboBox
我認(rèn)為很關(guān)鍵的兩點(diǎn)是API函數(shù)SendMessage的調(diào)用和KeyPress代碼段e.Handled = True的應(yīng)用。
If the event is not handled, it will be sent to the operating system for default processing. Set Handled to true to cancel the KeyPress event.
Control's code:(100%原創(chuàng))

??Public?Class?XComBoClass?XComBo
????
Inherits?System.Windows.Forms.ComboBox

#Region?
"?Windows?Form?Designer?generated?code?"

????Public?Sub?New()Sub?New()
????????
MyBase.New()

????????
'This?call?is?required?by?the?Windows?Form?Designer.
????????InitializeComponent()

????????
'Add?any?initialization?after?the?InitializeComponent()?call

????
End?Sub


????
'UserControl1?overrides?dispose?to?clean?up?the?component?list.
????Protected?Overloads?Overrides?Sub?Dispose()Sub?Dispose(ByVal?disposing?As?Boolean)
????????
If?disposing?Then
????????????
If?Not?(components?Is?Nothing)?Then
????????????????components.Dispose()
????????????
End?If
????????
End?If
????????
MyBase.Dispose(disposing)
????
End?Sub


????
'Required?by?the?Windows?Form?Designer
????Private?components?As?System.ComponentModel.IContainer

????
'NOTE:?The?following?procedure?is?required?by?the?Windows?Form?Designer
????'It?can?be?modified?using?the?Windows?Form?Designer.??
????'Do?not?modify?it?using?the?code?editor.
????<System.Diagnostics.DebuggerStepThrough()>?Private?Sub?InitializeComponent()Sub?InitializeComponent()
????????components?
=?New?System.ComponentModel.Container
????
End?Sub


#
End?Region

????
Private?Declare?Function?SendMessage()Function?SendMessage?Lib?"user32.dll"?Alias?"SendMessageA"?(ByVal?hwnd?As?Integer,?ByVal?wMsg?As?Integer,?ByVal?wParam?As?Integer,?ByVal?lParam?As?Integer)?As?Integer
????
Private?Const?CB_SHOWDROPDOWN?=?&H14F

????
Private?Sub?ComboDropdown()Sub?ComboDropdown()
????????SendMessage(Handle.ToInt32,?CB_SHOWDROPDOWN,?
1,?0&)
????
End?Sub


????
Protected?Overrides?Sub?OnKeyPress()Sub?OnKeyPress(ByVal?e?As?System.Windows.Forms.KeyPressEventArgs)

????????
Dim?str,?strCurrentText?As?String

????????
If?((Asc(e.KeyChar)?=?13)?And?(Asc(e.KeyChar)?=?8))?Then?Exit?Sub

????????ComboDropdown()
????????strCurrentText?
=?Mid(Text,?1,?Text.Length?-?SelectedText.Length)?&?CStr(e.KeyChar)
????????
str?=?CStr(strCurrentText)
????????
Dim?Index?As?Integer?=?FindString(str)
????????
If?Index?>=?0?Then
????????????SelectedIndex?
=?Index
????????????[
Select](str.Length,?Items(Index).length?-?str.Length)
????????????e.Handled?
=?True
????????
End?If
????
End?Sub


End?Class





轉(zhuǎn)載于:https://www.cnblogs.com/rippleyong/archive/2004/06/30/19780.html

總結(jié)

以上是生活随笔為你收集整理的100% .NET Control_自动完成Combobox的XComBo控件(VB.NET)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。