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