Click here to Skip to main content
15,894,252 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have datagridview on my window form of vb.net project. i put following code to call the textbox4 on datagridview of column 3
If Not e.RowIndex = -1 Then
           If e.ColumnIndex = 3 Then
               TextBox4 = New TextBox()
               DgTotalInput.Controls.Add(TextBox4)
               Dim oRectangle As Rectangle = DgTotalInput.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True)
               TextBox4.Size = New Size(oRectangle.Width, oRectangle.Height)
               TextBox4.Location = New Point(oRectangle.X, oRectangle.Y)
               TextBox4.Focus()

from above code i call textbox to datagrid
but to autocomplete i attached column 3 rows data to AutoCompleteStringCollection
i.e.
Dim col As New AutoCompleteStringCollection

and code is
For i = 0 To DgTotalInput.Rows.Count - 2
            col.Add(DgTotalInput.Rows(i).Cells(3).Value)
        Next
        TextBox4.AutoCompleteCustomSource = col
        TextBox4.AutoCompleteSource = AutoCompleteSource.CustomSource


when i type letters in textbox4 it shows suggestions correctly but problem arises when i type letters when textbox in on grid it dont shows suggestions why? and what is solution ?

What I have tried:

Private Sub TextBox4_GotFocus(sender As Object, e As EventArgs) Handles TextBox4.GotFocus
       Dim col As New AutoCompleteStringCollection
       For i = 0 To DgTotalInput.Rows.Count - 2
           col.Add(DgTotalInput.Rows(i).Cells(3).Value)
       Next
       TextBox4.AutoCompleteCustomSource = col
       TextBox4.AutoCompleteSource = AutoCompleteSource.CustomSource
   End Sub
Posted
Comments
[no name] 17-Sep-20 11:37am    
You seem to be creating a completion list from the same column you're updating. If you start with no rows / column values, then no completion list. Chicken and egg.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900