I need AutoComplete functionality for RadTextBoxControl that will allow me to identify the object selected by the user.
Public Class Person
Public Property GuidPerson As Guid
Public Property FirstName As String
Public Property LastName As String
Public ReadOnly Property FullName As String
Get
Return String.Format("{0} {1}", FirstName, LastName)
End Get
End Property
Public Sub New(fName As String, lname As String)
GuidPerson = Guid.NewGuid
FirstName = fName
LastName = lname
End Sub
End Class
Public Class RadForm4
Private listPerson As New List(Of Person)
Public Sub New()
InitializeComponent()
listPerson.Add(New Person("John", "Snow"))
listPerson.Add(New Person("Arya", "Stark"))
listPerson.Add(New Person("Brandon", "Stark"))
listPerson.Add(New Person("Catelyn", "Stark"))
RadTextBoxControl1.AutoCompleteMode = AutoCompleteMode.Suggest
RadTextBoxControl1.AutoCompleteDataSource = listPerson
RadTextBoxControl1.AutoCompleteDisplayMember = "FullName"
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
'HOW TAKE 'GuidPerson' from selected item in RadTextBoxControl1
End Sub
End Class
How to capture a user-selected object?
For example, in RadDropDownList I would do it like this:
Dim searchValue As Person = TryCast(RadDropDownList1.SelectedItem.DataBoundItem, Person)
I don't want to use RadAutoCompleteBox because I want to display the results text and not tokens
Regards
Jack