子字符串上的组合框自动完成 [英] ComboBox AutoComplete on SubString
问题描述
在我的一个 WinForms 应用程序中,我有一个带有 ComboBox 的窗口,供用户从中选择客户.
In one of my WinForms applications, I have a window with a ComboBox for the user to select a customer from.
此列表框中的客户采用以下格式:CustomerID - CustomerName",例如004540 - NorthWind Traders"
The customers in this list box are in this format : "CustomerID - CustomerName", for example "004540 - NorthWind Traders"
本机 WinForms 组合框有一个内置的自动完成功能,而且效果很好:问题在于它只能从组合框列表中每个项目的字符串的开头匹配,而不是从任何地方(子字符串)匹配.
The native WinForms combobox has an autocomplete feature built-in and it works well: the problem is that it only works by matching from the beginning of the string of each item of the combobox's list and not from anywhere (substring).
我希望我的用户能够做的是输入 CustomerID 或 CustomerName 的任何一种类型,因为高级用户熟悉大多数 CustomerID,而新员工将受益于能够输入 CustomerName 并获得自动完成功能.这意味着我实际上想从列表中寻找最佳匹配,其中输入的文本是 ComboBox 项的子字符串.
What I would like my users to be able to do is to either type of the CustomerID or CustomerName, as senior users are familiar with most CustomerIDs while new recruits would benefit from being able to type the CustomerName in and get the AutoComplete anyway. That means that I actually want to look for the best match from the list where the inputted text is a substring of the ComboBox item.
通常针对这种情况建议的解决方案是创建一个仅在用户键入时显示的隐藏列表框,但我对此并不满意,因为它感觉像是快速破解并且不容易重用,并且与标准 ComboBox 控件相比,其外观和行为可能不一致.
A solution often suggested for this kind of scenario is to create a hidden list box that only shows up when the user types, but I'm not happy with that as it feels like a quick hack and is not easily reusable, and may look and behave inconsistently compared to the standard ComboBox control.
我尝试自己使用 DroppedDown 属性来实现这个列表,并使用 SelectedIndex 来设置项目,但是当我这样做时组合框的文本框的内容会被重置,而我只想要最佳匹配item"从组合框列表中突出显示(我需要建议"而不是附加",附加模式无论如何都不能真正与子字符串匹配一起使用).
I've tried to implement this myself using the DroppedDown property to make the list appear and use SelectedIndex to set the item but the content of the combobox's textbox is reset when I do that, while I only would like the "best matching item" to be highlighted from the ComboBox lists (I need "Suggest" and not "Append", Append-mode can not be really be used with substring-matching anyway).
我认为一定有更好的方法吗?如果有人知道这样做的自定义/第 3 方控件,我也不反对购买.
I think that there must be a better way? If anyone knows of a custom / 3rd Party control doing this, I'm not against buying one either.
谢谢.
PS:我正在使用 C# 为 WinForms 编程,使用 .Net Framework 3.5.
PS: I am programming in C# for WinForms, with .Net Framework 3.5.
推荐答案
好吧,我有一些代码供您尝试.它不是一个组合框,而是一个自动完成的文本框,带有按照您的要求执行的修改.
Well, I have some code for you to try. Its not a combo box, but it is an autocomplete text box with modifications that perform as you are requesting.
将代码复制到新表单中.然后在做任何其他事情之前,保存并构建.然后转到表单设计器并将一个新的 ClsCustomAutoCompleteTextbox 拖到您的表单上.
Copy the code into a new form. Then before doing anything else, save and build. Then go to the form designer and drag a new ClsCustomAutoCompleteTextbox onto your form.
然后你应该能够运行它.我确实意识到您想要 C#(至少现在我意识到了这一点).在 VB 中试试这个,看看这是不是你想要的,我可以把它转换成 C#.
Then you should be able to run it. I do realize that you are wanting C# (At least now I realize that). Try this in VB and see if this is what you want, and I can convert it to C#.
Public Class Form1
Dim MasterList As New List(Of String)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim L As New List(Of String)
L.Add("123123 - Bob")
L.Add("534543 - Sally")
L.Add("123123 - George")
L.Add("34213 - Happy")
MasterList = L
Me.ClsCustomAutoCompleteTextbox1.AutoCompleteList = L
End Sub
Private Sub ClsCustomAutoCompleteTextbox1_BeforeDisplayingAutoComplete(ByVal sender As Object, ByVal e As clsCustomAutoCompleteTextbox.clsAutoCompleteEventArgs) Handles ClsCustomAutoCompleteTextbox1.BeforeDisplayingAutoComplete
Dim Name As String = Me.ClsCustomAutoCompleteTextbox1.Text.ToLower
Dim Display As New List(Of String)
For Each Str As String In MasterList
If Str.ToLower.IndexOf(Name) > -1 Then
Display.Add(Str)
End If
Next
e.AutoCompleteList = Display
e.SelectedIndex = 0
End Sub
End Class
#Region "clsCustomAutoCompleteTextbox"
Public Class clsCustomAutoCompleteTextbox
Inherits TextBox
Event BeforeDisplayingAutoComplete(ByVal sender As Object, ByVal e As clsAutoCompleteEventArgs)
Event ItemSelected(ByVal sender As Object, ByVal e As clsItemSelectedEventArgs)
Public test As New List(Of String)
Public Tabs As Integer = 0
Private Function GetLastFunction(Optional ByVal Deep As Integer = 1) As System.Reflection.MethodInfo
Dim ST As New StackTrace
Dim Frame As StackFrame = ST.GetFrame(Deep)
Return Frame.GetMethod()
End Function
Private Sub TempLogStart()
'Dim Meth As System.Reflection.MethodInfo = GetLastFunction(3)
'test.Add(Now & " - " & New String(" ", Tabs * 2) & "Started " & Meth.Module.Name & "." & Meth.Name)
'Tabs += 1
End Sub
Private Sub TempLogStop()
' Dim Meth As System.Reflection.MethodInfo = GetLastFunction(3)
' Tabs -= 1
' test.Add(Now & " - " & New String(" ", Tabs * 2) & "Stopped " & Meth.Module.Name & "." & Meth.Name)
End Sub
Public Enum SelectOptions
OnEnterPress = 1
OnSingleClick = 2
OnDoubleClick = 4
OnTabPress = 8
OnRightArrow = 16
OnEnterSingleClick = 3
OnEnterSingleDoubleClicks = 7
OnEnterDoubleClick = 5
OnEnterTab = 9
'OnItemChange = 32
End Enum
Private mSelStart As Integer
Private mSelLength As Integer
Private myAutoCompleteList As New List(Of String)
Private WithEvents myLbox As New ListBox
Private WithEvents myForm As New Form
Private WithEvents myParentForm As Form
Private DontHide As Boolean = False
Private SuspendFocus As Boolean = False
Dim Args As clsAutoCompleteEventArgs
WithEvents HideTimer As New Timer()
WithEvents FocusTimer As New Timer()
Private myShowAutoCompleteOnFocus As Boolean
Private myAutoCompleteFormBorder As System.Windows.Forms.FormBorderStyle = FormBorderStyle.None
Private myOnEnterSelect As Boolean
Private mySelectionMethods As SelectOptions = (SelectOptions.OnDoubleClick Or SelectOptions.OnEnterPress)
Private mySelectTextAfterItemSelect As Boolean = True
Public Property SelectTextAfterItemSelect() As Boolean
Get
Return mySelectTextAfterItemSelect
End Get
Set(ByVal value As Boolean)
mySelectTextAfterItemSelect = value
End Set
End Property
<System.ComponentModel.Browsable(False)> _
Public Property SelectionMethods() As SelectOptions
Get
Return mySelectionMethods
End Get
Set(ByVal value As SelectOptions)
mySelectionMethods = value
End Set
End Property
Public Property OnEnterSelect() As Boolean
Get
Return myOnEnterSelect
End Get
Set(ByVal value As Boolean)
myOnEnterSelect = value
End Set
End Property
Public Property AutoCompleteFormBorder() As System.Windows.Forms.FormBorderStyle
Get
Return myAutoCompleteFormBorder
End Get
Set(ByVal value As System.Windows.Forms.FormBorderStyle)
myAutoCompleteFormBorder = value
End Set
End Property
Public Property ShowAutoCompleteOnFocus() As Boolean
Get
Return myShowAutoCompleteOnFocus
End Get
Set(ByVal value As Boolean)
myShowAutoCompleteOnFocus = value
End Set
End Property
Public ReadOnly Property Lbox() As ListBox
Get
Return myLbox
End Get
End Property
Public Property AutoCompleteList() As List(Of String)
Get
Return myAutoCompleteList
End Get
Set(ByVal value As List(Of String))
myAutoCompleteList = value
End Set
End Property
Private Sub TryHideFormWindowsDeactivated()
End Sub
Private Declare Auto Function GetForegroundWindow Lib "user32.dll" () As IntPtr
Private Declare Auto Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hWnd As IntPtr, ByRef ProcessID As Integer) As Integer
Private Function IsCurProcess(ByVal P As Process) As Boolean
Dim Ptr As IntPtr = P.MainWindowHandle
End Function
Private Function AppHasFocus(Optional ByVal ExeNameWithoutExtension As String = "") As Boolean
Dim Out As Boolean = False
Dim PID As Integer = 0
TempLogStart()
If ExeNameWithoutExtension = "" Then
ExeNameWithoutExtension = Process.GetCurrentProcess.ProcessName
End If
Dim activeHandle As IntPtr = GetForegroundWindow()
Call GetWindowThreadProcessId(activeHandle, PID)
If PID > 0 Then
'For Each p As Process In Process.GetProcessesByName(ExeNameWithoutExtension)
If PID = Process.GetCurrentProcess.Id Then
Out = True
'Exit For
End If
' Next
End If
TempLogStop()
Return Out
End Function
Private Sub SaveSelects()
Me.mSelStart = Me.SelectionStart
Me.mSelLength = Me.SelectionLength
End Sub
Private Sub LoadSelects()
Me.SelectionStart = Me.mSelStart
Me.SelectionLength = Me.mSelLength
End Sub
Private Sub ShowAutoComplete()
TempLogStart()
Args = New clsAutoCompleteEventArgs()
With Args
.Cancel = False
.AutoCompleteList = Me.myAutoCompleteList
If myLbox.SelectedIndex = -1 Then
.SelectedIndex = 0
Else
.SelectedIndex = myLbox.SelectedIndex
End If
End With
RaiseEvent BeforeDisplayingAutoComplete(Me, Args)
Me.myAutoCompleteList = Args.AutoCompleteList
'If Me.myAutoCompleteList IsNot Nothing AndAlso Me.myAutoCompleteList.Count - 1 < Args.SelectedIndex Then
' Args.SelectedIndex = Me.myAutoCompleteList.Count - 1
'End If
If Not Args.Cancel AndAlso Args.AutoCompleteList IsNot Nothing AndAlso Args.AutoCompleteList.Count > 0 Then
Call DoShowAuto()
Else
Call DoHideAuto()
End If
TempLogStop()
End Sub
Private Sub DoShowAuto()
Call SaveSelects()
TempLogStart()
Static First As Boolean = True
myLbox.BeginUpdate()
Try
myLbox.Items.Clear()
myLbox.Items.AddRange(Me.myAutoCompleteList.ToArray)
Call Me.MoveLBox(Args.SelectedIndex)
Catch ex As Exception
End Try
myLbox.EndUpdate()
myParentForm = GetParentForm(Me)
If myParentForm IsNot Nothing Then
myLbox.Name = "mmmlbox" & Now.Millisecond
If myForm.Visible = False Then
myForm.Font = Me.Font
myLbox.Font = Me.Font
myLbox.Visible = True
myForm.Visible = False
myForm.ControlBox = False
myForm.Text = ""
If First Then
myForm.Width = Me.Width
myForm.Height = 200
End If
First = False
If Not myForm.Controls.Contains(myLbox) Then myForm.Controls.Add(myLbox)
myForm.FormBorderStyle = FormBorderStyle.None
myForm.ShowInTaskbar = False
With myLbox
.Dock = DockStyle.Fill
.SelectionMode = SelectionMode.One
End With
'Frm.Controls.Add(myLbox)
DontHide = True
SuspendFocus = True
myForm.TopMost = True
myForm.FormBorderStyle = Me.myAutoCompleteFormBorder
myForm.BringToFront()
Call MoveDrop()
myForm.Visible = True
myForm.Show()
Call MoveDrop()
HideTimer.Interval = 10
Me.Focus()
SuspendFocus = False
HideTimer.Enabled = True
DontHide = False
Call LoadSelects()
End If
End If
TempLogStop()
End Sub
Sub MoveDrop()
TempLogStart()
Dim Pnt As Point = New Point(Me.Left, Me.Top + Me.Height + 2)
Dim ScreenPnt As Point = Me.PointToScreen(New Point(-2, Me.Height))
'Dim FrmPnt As Point = Frm.PointToClient(ScreenPnt)
If myForm IsNot Nothing Then
myForm.Location = ScreenPnt
'myForm.BringToFront()
'myForm.Focus()
'myLbox.Focus()
'Me.Focus()
End If
TempLogStop()
End Sub
Sub DoHide(ByVal sender As Object, ByVal e As EventArgs)
TempLogStart()
Call HideAuto()
TempLogStop()
End Sub
Private Sub DFocus(Optional ByVal Delay As Integer = 10)
TempLogStart()
FocusTimer.Interval = Delay
FocusTimer.Start()
TempLogStop()
End Sub
Private Sub DoHideAuto()
TempLogStart()
myForm.Hide()
HideTimer.Enabled = False
FocusTimer.Enabled = False
TempLogStop()
End Sub
Private Sub HideAuto()
TempLogStart()
If myForm.Visible AndAlso HasLostFocus() Then
Call DoHideAuto()
End If
TempLogStop()
End Sub
Private Function HasLostFocus() As Boolean
TempLogStart()
Dim Out As Boolean
If Me.myForm Is Nothing OrElse myForm.ActiveControl IsNot Me.myLbox Then
Out = True
End If
If Me.myParentForm Is Nothing OrElse Me.myParentForm.ActiveControl IsNot Me Then
Out = True
End If
TempLogStop()
Return Out
End Function
Private Function GetParentForm(ByVal InCon As Control) As Form
TempLogStart()
Dim TopCon As Control = FindTopParent(InCon)
Dim Out As Form = Nothing
If TypeOf TopCon Is Form Then
Out = CType(TopCon, Form)
End If
TempLogStop()
Return Out
End Function
Private Function FindTopParent(ByVal InCon As Control) As Control
TempLogStart()
Dim Out As Control
If InCon.Parent Is Nothing Then
Out = InCon
Else
Out = FindTopParent(InCon.Parent)
End If
TempLogStop()
Return Out
End Function
Public Class clsAutoCompleteEventArgs
Inherits EventArgs
Private myAutoCompleteList As List(Of String)
Private myCancel As Boolean
Private mySelectedIndex As Integer
Public Property SelectedIndex() As Integer
Get
Return mySelectedIndex
End Get
Set(ByVal value As Integer)
mySelectedIndex = value
End Set
End Property
Public Property Cancel() As Boolean
Get
Return myCancel
End Get
Set(ByVal value As Boolean)
myCancel = value
End Set
End Property
Public Property AutoCompleteList() As List(Of String)
Get
Return myAutoCompleteList
End Get
Set(ByVal value As List(Of String))
myAutoCompleteList = value
End Set
End Property
End Class
Protected Overrides Sub OnKeyUp(ByVal e As System.Windows.Forms.KeyEventArgs)
TempLogStart()
TempLogStop()
MyBase.OnKeyUp(e)
Call ShowOnChar(Chr(e.KeyValue))
End Sub
Private Sub ShowOnChar(ByVal C As String)
TempLogStart()
TempLogStop()
If IsPrintChar(C) Then
Call Me.ShowAutoComplete()
End If
End Sub
Private Function IsPrintChar(ByVal C As Integer) As Boolean
TempLogStart()
TempLogStop()
Return IsPrintChar(Chr(C))
End Function
Private Function IsPrintChar(ByVal C As Byte) As Boolean
TempLogStart()
TempLogStop()
Return IsPrintChar(Chr(C))
End Function
Private Function IsPrintChar(ByVal C As Char) As Boolean
TempLogStart()
TempLogStop()
Return IsPrintChar(C.ToString)
End Function
Private Function IsPrintChar(ByVal C As String) As Boolean
TempLogStart()
If System.Text.RegularExpressions.Regex.IsMatch(C, "[^
fv]") Then
Return True
Else
Return False
End If
TempLogStop()
End Function
Private Sub clsCustomAutoCompleteTextbox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
TempLogStart()
If Not Me.SuspendFocus AndAlso Me.myShowAutoCompleteOnFocus AndAlso Me.myForm.Visible = False Then
Call Me.ShowAutoComplete()
End If
TempLogStop()
End Sub
Private Sub clsCustomAutoCompleteTextbox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
TempLogStart()
If Not SelectItem(e.KeyCode) Then
If e.KeyCode = Keys.Up Then
If myLbox.SelectedIndex > 0 Then
Call MoveLBox(myLbox.SelectedIndex - 1)
End If
ElseIf e.KeyCode = Keys.Down Then
Call MoveLBox(myLbox.SelectedIndex + 1)
End If
End If
TempLogStop()
End Sub
Shadows Sub SelectAll()
End Sub
Private Sub MoveLBox(ByVal Index As Integer)
TempLogStart()
Try
If Index > myLbox.Items.Count - 1 Then
Index = myLbox.Items.Count - 1
End If
myLbox.SelectedIndex = Index
Catch ex As Exception
End Try
TempLogStop()
End Sub
Private Sub clsCustomAutoCompleteTextbox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave
TempLogStart()
Call DoHide(sender, e)
TempLogStop()
End Sub
Private Sub clsCustomAutoCompleteTextbox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
TempLogStart()
Call DoHide(sender, e)
TempLogStop()
End Sub
Private Sub clsCustomAutoCompleteTextbox_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
TempLogStart()
Call MoveDrop()
TempLogStop()
End Sub
Private Sub clsCustomAutoCompleteTextbox_ParentChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ParentChanged
TempLogStart()
myParentForm = GetParentForm(Me)
TempLogStop()
End Sub
Private Sub HideTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles HideTimer.Tick
TempLogStart()
Call MoveDrop()
Call DoHide(sender, e)
Static Cnt As Integer = 0
Cnt += 1
If Cnt > 300 Then
If Not AppHasFocus() Then
Call DoHideAuto()
End If
Cnt = 0
End If
TempLogStop()
End Sub
Public Overrides Property SelectedText() As String
Get
Return MyBase.SelectedText
End Get
Set(ByVal value As String)
MyBase.SelectedText = value
End Set
End Property
Public Overrides Property SelectionLength() As Integer
Get
Return MyBase.SelectionLength
End Get
Set(ByVal value As Integer)
MyBase.SelectionLength = value
End Set
End Property
Private Sub myLbox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles myLbox.Click
End Sub
Private Sub myLbox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles myLbox.DoubleClick
End Sub
Private Function SelectItem(Optional ByVal Key As Keys = Keys.None, _
Optional ByVal SingleClick As Boolean = False, _
Optional ByVal DoubleClick As Boolean = False) As Boolean
TempLogStart()
Dim DoSelect As Boolean = True
Dim Meth As SelectOptions
Static LastItem As Integer = -1
Select Case True
Case Me.mySelectionMethods And SelectOptions.OnEnterPress AndAlso Key = Keys.Enter
Meth = SelectOptions.OnEnterPress
Case Me.mySelectionMethods And SelectOptions.OnRightArrow AndAlso Key = Keys.Right
Meth = SelectOptions.OnRightArrow
Case Me.mySelectionMethods And SelectOptions.OnTabPress AndAlso Key = Keys.Tab
Meth = SelectOptions.OnTabPress
Case Me.mySelectionMethods And SelectOptions.OnSingleClick AndAlso SingleClick
Meth = SelectOptions.OnSingleClick
Case Me.mySelectionMethods And SelectOptions.OnDoubleClick AndAlso DoubleClick
Meth = SelectOptions.OnDoubleClick
'Case Me.mySelectionMethods And SelectOptions.OnItemChange AndAlso (LastItem <> myLbox.SelectedIndex)
Case Else
DoSelect = False
End Select
LastItem = myLbox.SelectedIndex
If DoSelect Then
Call DoSelectItem(Meth)
End If
TempLogStop()
Return DoSelect
End Function
Private Sub DoSelectItem(ByVal Method As SelectOptions)
TempLogStart()
If Me.myLbox.Items.Count > 0 AndAlso Me.myLbox.SelectedIndex > -1 Then
Dim Value As String = Me.myLbox.SelectedItem.ToString
Dim Orig As String = Me.Text
Me.Text = Value
If mySelectTextAfterItemSelect Then
Try
Me.SelectionStart = Orig.Length
Me.SelectionLength = Value.Length - Orig.Length
Catch ex As Exception
End Try
Else
'Me.SelectionStart = Me.Text.Length
'Me.SelectionLength = 0
End If
RaiseEvent ItemSelected(Me, New clsItemSelectedEventArgs(Me.myLbox.SelectedIndex, Method, Value))
Call Me.DoHideAuto()
End If
TempLogStop()
End Sub
Public Class clsItemSelectedEventArgs
Private myIndex As Integer
Private myMethod As SelectOptions
Private myItemText As String
Public Property ItemText() As Boolean
Get
Return myItemText
End Get
Set(ByVal value As Boolean)
myItemText = value
End Set
End Property
Public Property Method() As SelectOptions
Get
Return myMethod
End Get
Set(ByVal value As SelectOptions)
myMethod = value
End Set
End Property
Public Property Index() As Integer
Get
Return myIndex
End Get
Set(ByVal value As Integer)
myIndex = value
End Set
End Property
Sub New()
End Sub
Sub New(ByVal Index As Integer, ByVal Method As SelectOptions, ByVal ItemText As String)
myIndex = Index
myMethod = Method
myItemText = ItemText
End Sub
End Class
Private Sub myLbox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles myLbox.GotFocus
TempLogStart()
Call DFocus()
TempLogStop()
End Sub
Private Sub myLbox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles myLbox.KeyDown
TempLogStart()
Call SelectItem(e.KeyCode)
TempLogStop()
End Sub
Private Sub ProcessKeyEvents(ByVal e As KeyEventArgs)
TempLogStart()
Select Case e.KeyCode
Case Is >= Keys.A And e.KeyCode <= Keys.Z
MyBase.OnKeyUp(e)
Case Keys.Back
Case Keys.Enter
Case Keys.Left, Keys.Right, Keys.Up, Keys.Down
Case Is >= Keys.NumPad0 And e.KeyCode <= Keys.NumPad9, Is >= Keys.D0 And e.KeyCode <= Keys.D9
End Select
TempLogStop()
End Sub
Private Sub myLbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles myLbox.KeyPress
If IsPrintChar(e.KeyChar) Then
'Me.OnKeyPress(e)
'Call MoveDrop()
End If
TempLogStop()
End Sub
Private Sub myLbox_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles myLbox.KeyUp
If IsPrintChar(e.KeyValue) Then
'Me.OnKeyUp(e)
'Call MoveDrop()
End If
TempLogStop()
End Sub
Private Sub myLbox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles myLbox.LostFocus
TempLogStart()
Call DoHide(sender, e)
TempLogStop()
End Sub
Private Sub myLbox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles myLbox.MouseClick
TempLogStart()
'If e.Button <> Windows.Forms.MouseButtons.None Then
Call SelectItem(SingleClick:=True)
'End If
TempLogStop()
End Sub
Private Sub myLbox_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles myLbox.MouseDoubleClick
TempLogStart()
'If e.Button <> Windows.Forms.MouseButtons.None Then
Call SelectItem(DoubleClick:=True)
'End If
TempLogStop()
End Sub
Private Sub myForm_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles myForm.Deactivate
TempLogStart()
Call TryHideFormWindowsDeactivated()
TempLogStop()
End Sub
Private Sub myParentForm_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles myParentForm.Deactivate
TempLogStart()
Call TryHideFormWindowsDeactivated()
TempLogStop()
End Sub
Private Sub FocusTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FocusTimer.Tick
TempLogStart()
Me.Focus()
TempLogStop()
End Sub
Public Sub New()
End Sub
Private Sub myLbox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles myLbox.MouseDown
myLbox_MouseClick(sender, e)
End Sub
End Class
#End Region
这篇关于子字符串上的组合框自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!