vbdotnet.it

Tricks & tips, workaround, forum and ideas with .Net

About the author

Enrico Rossini è il gestore di questo blog.
E-mail me Send mail

Recent posts

Recent comments

Contributi

Best 6 ~ 6 users ~ 6 comments

Info legali

Le opinioni espresse in questo blog sono strettamente personali e ogni persona è responsabile dei commenti che inserisce. I marchi citati sono delle rispettive aziende.

© Copyright 2010

Advertising


Creare un combobox con ricerca

Per quanto hai cercato un combobox con la possibilità di ricerca? Ecco una semplice implementazione:

Private Sub CombBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        
Dim findString As String = String.Empty
        
If (Not e.KeyChar.IsLetterOrDigit(e.KeyChar, 0)) Then Exit Sub
        findString = e.KeyChar
        
With ComboBox1
            .SelectedIndex = ComboBox1.FindString(findString)
        
End With
        If ComboBox1.SelectedIndex > -1 Then e.Handled = True
End
Sub

Ciao a tutti!

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Tuesday, September 15, 2009 12:14 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Cercare un elemento in un combobox

Chissà a quanti è capitato di dover cercare all'interno di un combobox un elemento presente (non un valore). Per risolvere il problema il comando da scrivere è piuttosto semplice:

Me.cb.SelectedIndex = Me.cb.FindString("valore")

Il comando FindString presente tra le proprietà del combobox restituisce un intero che è la posizione del valore cercato all'interno degli elementi presenti nel combobox. In questo caso si è scelto di selezionare il valore trovato.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Tuesday, September 15, 2009 12:03 PM
Permalink | Comments (0) | Post RSSRSS comment feed