CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2007
    Posts
    38

    Textbox autocomplete string collection Help

    Dear Expert,

    I have made taken one textbox in form, in which i have written following logic in Got Focus event.

    When i focus on that its automatically showing all the suggested name from database field.

    CODE:-

    Code:
    Private Sub CustomerName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CustomerName.GotFocus
    
            da = New SqlDataAdapter("Select CustomerName from CustomerMaster", myConnection)
            da.Fill(ds, "CustomerMaster")
            
            Dim acFirstName As New AutoCompleteStringCollection
    
            For Each dr As DataRow In Me.ds.Tables("CustomerMaster").Rows
                acFirstName.Add(dr.Item("CustomerName").ToString)
            Next
            CustomerName.AutoCompleteCustomSource = acFirstName
    
        End Sub
    I want that if suppose, i will type some other name which is not exist in autocomplete string collection then its should gives error.

    Please guide me.

    Regards,
    AKM

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Textbox autocomplete string collection Help

    What I would do is to loop through the items in the listbox array ( most likely on each key press ), then if there is no match found produce the error message. You can find if certain strings match by simple string manipulation techniques. There is a FAQ about string manipulation here :

    http://www.codeguru.com/forum/forumdisplay.php?f=93

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured