As VB index help

  • Thread starter Thread starter giannis
  • Start date Start date
G

giannis

I like the feature in the VB index help, that user types in first
serveral characters, the list will jump to the first match.
How can i do this in VB with the combination of a combo box
and list box or with the combination of a text box and list box ?
Is this possible ? What events must i use for this ?
Any idea is acceptable .
Thanx !
 
What are you trying to do? You can do this so a combobox itself. So is
there some particular reason you want to do it with two controls?

Robin S.
 
giannis said:
How can i do this with a combo box ?

giannis,

Here's an example.

On the combobox:
Set AutoCompleteMode to SuggestAppend.
Set AutoCompleteSource to CustomSource.

'this loads my combobox and binds it
Private Sub LoadManagerComboBox()
If MgrList IsNot Nothing AndAlso MgrList.Count > 0 Then
MgrList = Nothing 'blank out the table
End If
'create the list that is going to be bound to the combobox
'this could just as easily be a datatable
MgrList = PTBO.ManagerList.Create(ManagerName)
'bind the combo box to the list
ManagerComboBox.DataSource = MgrList
ManagerComboBox.DisplayMember = "FullName"
ManagerComboBox.ValueMember = "UserID"
ManagerComboBox.SelectedIndex = -1
Call BuildAutoCompleteStrings()
End Sub

'this builds the autocomplete strings
Private Sub BuildAutoCompleteStrings()
'If the manager list doesn't have any entries, return.
If MgrList.Count <= 0 _
OrElse ManagerComboBox.Items.Count <= 0 Then
Return
End If
' Clear what is in there now
ManagerComboBox.AutoCompleteCustomSource.Clear()
'Set the column name.
Dim filterField As String = "FullName"
' Build the list of filter values.
Dim filterVals As AutoCompleteStringCollection = _
New AutoCompleteStringCollection()
For Each dataItem As Object In MgrList
Dim props As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(dataItem)
Dim propDesc As PropertyDescriptor = _
props.Find(filterField, True)
Dim fieldVal As String = _
propDesc.GetValue(dataItem).ToString()
filterVals.Add(fieldVal)
Next
' Set the list on the collection.
ManagerComboBox.AutoCompleteCustomSource = filterVals
End Sub


Good luck,
Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
 
RobinS said:
Here's an example.

I am a newbie at VB.
I dont understand all these ...
What ebooks you suggest me to read ?
I care about build a program with a mdb database in VB.
(I dont care about SQL servers databases)
Thank you for your care and sorry about my english !!!
 
If you are using Access instead of SQL, you just use the OLEDBDataAdapter
instead of SQLDataAdapter, OLEDBCONnection instead of SQLConnection,
OLEDBCommand instead of SQLCommand (are you getting the pattern here?).

I don't use Access as a back-end any more, so I don't know what books that
is covered in. Dave Sceppa talks about it in his ADO.Net Core Reference
book, but not in detail. I think most everything he talks about for
SQLServer applies to Access, give or take the way it does named parameters
and a few more complicated details.

The example that I posted is binding a combobox to a List(Of Manager)
object and then setting up the autocomplete stuff so when somebody starts
typing into the combobox, it can try to complete their selection.

Do you have *any* prior programming experience, and if so, in what
languages?

Robin S.
-----------------------------------------
 
RobinS said:
If you are using Access instead of SQL, you just use the
OLEDBDataAdapter instead of SQLDataAdapter, OLEDBCONnection instead
of SQLConnection, OLEDBCommand instead of SQLCommand (are you getting
the pattern here?).

Thanks for your advices !!!
The example that I posted is binding a combobox to a List(Of Manager)
object and then setting up the autocomplete stuff so when somebody
starts typing into the combobox, it can try to complete their
selection.

MgrList = PTBO.ManagerList.Create(ManagerName)

I receive the error PTBO is not declared . What is this ? (PTBO)
I receive the error ManagerName is not declared . Is a string ?
Do you have *any* prior programming experience, and if so, in what
languages?

A little VB6 and VBAccess
 
When i use the :
Dim adapter As OleDbDataAdapter
i receive the error that is not defined :(
 
Read the comments in the code.

'create the list that is going to be bound to the combobox
'this could just as easily be a datatable
MgrList = PTBO.ManagerList.Create(ManagerName)

Robin S.
--------------------------------
 
Back
Top