VB.NET Winforms Application ...当用户开始在应用程序的搜索框中输入时,它会自动使用有效结果填充名称列表下拉框并将下拉值设置为true ...一切正常用户被迫从名单中选择一个值或按esc键这一事实,因为没有这样做,鼠标光标就会消失,你必须将鼠标一直移到应用程序之外才能返回它只有在应用程序之外才这样做。下面是我正在使用的代码,应该注意我在应用程序中使用了下拉值,否则这些实例都没有问题只有这一个..任何想法???
Private Sub u_lastName_Box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles u_lastName_Box.TextChanged
u_nameLook_Box.Items.Clear()
Dim TenList As New List(Of tenant)
Dim x As List(Of tenant) = db.tenants.Where(Function(f) f.last_name.Contains(u_lastName_Box.Text) AndAlso f.propertyId = selectedProperty).OrderBy(Function(f) f.last_name).ToList
For Each _ten In x
Dim c = _ten
u_nameLook_Box.Items.Add(Convert.ToString(c.Occupantid) + " -- " + c.last_name + "," + c.first_name)
Next
RemoveHandler u_nameLook_Box.DropDown, AddressOf u_nameLook_Box_DropDown
u_nameLook_Box.DroppedDown = True
AddHandler u_nameLook_Box.DropDown, AddressOf u_nameLook_Box_DropDown
End Sub
答案 0 :(得分:2)
我遇到了同样的问题,我解决了这个问题"更新"鼠标状态,
ComboBoxClients.DroppedDown = True
Cursor.Current = Cursors.Default
答案 1 :(得分:1)
我实际上刚刚解决了这个问题,我在晚上考虑了它。我尝试了没有骰子的cursor.show ...我想了一点,并决定在光标之前设置光标样式。 show并且它现在正常工作...我的更新代码如下......关于光标样式和可见性如何或者为什么在第一时间发生变化存在一些问题......
Private Sub u_lastName_Box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles u_lastName_Box.TextChanged
u_nameLook_Box.Items.Clear()
If Not u_lastName_Box.Text.Length < 1 Then
Dim TenList As New List(Of tenant)
Dim x As List(Of tenant) = db.tenants.Where(Function(f) f.last_name.Contains(u_lastName_Box.Text) AndAlso f.propertyId = selectedProperty).OrderBy(Function(f) f.last_name).ToList
For Each _ten In x
Dim c = _ten
u_nameLook_Box.Items.Add(Convert.ToString(c.Occupantid) + " -- " + c.last_name + "," + c.first_name)
Next
RemoveHandler u_nameLook_Box.DropDown, AddressOf u_nameLook_Box_DropDown
u_nameLook_Box.DroppedDown = True
Me.Cursor = Cursors.Default
Cursor.Show()
AddHandler u_nameLook_Box.DropDown, AddressOf u_nameLook_Box_DropDown
Else
u_lookup_boxes_fill()
End If
End Sub