2012-06-08 32 views
2

VB.NET Winforms Application ...当用户开始在应用程序的搜索框中输入内容时,它会自动填充名称列表下拉框并显示有效结果并设置下拉值为真...一切工作正常,除了用户被迫从名称列表中选择一个值或按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 

回答

1

思考了一夜后,我竟然修复了这个问题刚才..我试过cursor.show没有骰子...我想多一点上,决定设置光标之前的风格到cursor.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 
1

我面临同样的问题,我解决了它“更新”鼠标状态,

ComboBoxClients.DroppedDown = True 

Cursor.Current = Cursors.Default 
相关问题