Fill combobox or textbox as user types in a DataGridView

johnpapa

Member
Joined
Aug 10, 2013
Messages
23
Programming Experience
10+
Just to help, I created the following video describing the problems which I am trying to solve.

DataGridView - YouTube

I am trying to move the software in the video (Access 2013) to the Cloud and I am using VS 2012 and SQL Server 2012.

I examined a suggestion of using the AutoComplete feature in a DGV. I ended up with the following code, which I placed in EditingControlShowing (which unfortunately is fired only once on enter of control). I tried to use CellValueChanged but cannot call the code from within this event.

VB.NET:
            GetPatientByLastFirstTel(dgvAppointment.CurrentCell.Value.ToString)
 
            Dim ItemCode As TextBox = TryCast(e.Control, TextBox)
            If ItemCode IsNot Nothing Then
                If dgvAppointment.CurrentCell.ColumnIndex = DFN_GRID_intPatientID_COL Then
                    With DirectCast(e.Control, TextBox)
 
                        .AutoCompleteMode = AutoCompleteMode.SuggestAppend
 
                        .AutoCompleteSource = AutoCompleteSource.CustomSource
 
                        .AutoCompleteCustomSource.AddRange(arymReturnArray)
 
                    End With
                Else
                    With DirectCast(e.Control, TextBox)
                        .AutoCompleteMode = AutoCompleteMode.None
                    End With
                End If
            End If
 
        End If

At the end of the day, I need to repopulate the dropdown list every time the user types a new character or deletes a character, just in case the name I am looking for is not included in the early dropdown lists.

Can you suggest the events I could use to implement this or another solution?

Thanks,
John
 
The SuggestAppend works ok now. The only problem is that I cannot use the up/down directional keys for selection from the dropdown list. I need to use the mouse for the selection.

Any ideas welcome.
John
 
Back
Top