vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
NEU! sevCoolbar 3.0 - Professionelle Toolbars im modernen Design!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Ein- und Umsteiger
Re: ComboBox Inhalt speichern 
Autor: Chief
Datum: 01.09.06 11:42

Hi KMX Racer Woh,

hier mal ne Klasse, das ganze kannste in einer dll packen und dann hast Du Deine AutocompleteComboBox

Public Class AutoCompleteComboBox
    Inherits System.Windows.Forms.ComboBox
 
    Dim sw As Boolean
 
    Sub New()
      Me.Sorted = True
    End Sub
 
    Protected Overrides Sub ontextchanged(ByVal e As EventArgs)
      MyBase.OnTextChanged(e)
      With Me
        If Len(.Text) > 0 Then
          If sw And Len(.Text) > 0 Then sw = False : Exit Sub
          sw = True
          Dim i As Integer = Me.FindString(Me.Text)
          If i >= 0 Then
            Dim k As Integer = Len(.Text)
            Me.SelectedIndex = i
            .SelectionStart = k
            .SelectionLength = Len(.Text) - k
          End If
        End If
      End With
      sw = False
    End Sub
 
    Protected Overrides Sub OnKeyDown(ByVal e As _
      System.Windows.Forms.KeyEventArgs)
      If e.KeyCode = Keys.Delete Then sw = True
      If e.KeyCode = Keys.Back And Me.SelectionStart > 0 Then
        Me.Text = Me.Text.Substring(0, Me.SelectionStart - 1)
      End If
      If e.KeyCode = Keys.Enter Then
        Dim i As Integer = Me.FindString(Me.Text)
        If i < 0 Then Me.Items.Add(Me.Text)
      End If
    End Sub
 
  End Class
[u]Und für die Nutzung:

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
    Dim ctl As New AutoCompleteComboBox
    With ctl
      .Top = 100
      .Left = 50
      .Width = 200
      .DropDownWidth = 200
      Me.Controls.Add(ctl)
      For i As Integer = 1 To 100
        Dim str As String = ""
        For k As Integer = 1 To CInt(5 + 20 * Rnd())
          str &= Chr(CInt(97 + 25 * Rnd()))
        Next
        .Items.Add(str)
      Next
    End With
  End Sub
Gruß
Chief

VB@rchiv its the Best

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
ComboBox Inhalt speichern2.998KMX Racer Woh30.08.06 09:21
Re: ComboBox Inhalt speichern1.765TiImann30.08.06 09:28
Re: ComboBox Inhalt speichern1.782KMX Racer Woh30.08.06 09:35
Re: ComboBox Inhalt speichern1.927TiImann30.08.06 10:25
Re: ComboBox Inhalt speichern1.687TiImann30.08.06 10:27
Re: ComboBox Inhalt speichern1.949viperbone30.08.06 10:32
Re: ComboBox Inhalt speichern1.698KMX Racer Woh30.08.06 10:34
Re: ComboBox Inhalt speichern1.819viperbone30.08.06 10:41
Re: ComboBox Inhalt speichern1.658KMX Racer Woh30.08.06 10:46
Re: ComboBox Inhalt speichern Problem!1.729KMX Racer Woh30.08.06 11:06
Re: ComboBox Inhalt speichern Problem!1.651viperbone30.08.06 11:25
Re: ComboBox Inhalt speichern Problem!1.655KMX Racer Woh30.08.06 11:38
Re: ComboBox Inhalt speichern Problem!2.206viperbone30.08.06 13:08
Re: ComboBox Inhalt speichern Problem!1.559KMX Racer Woh30.08.06 13:58
Re: ComboBox Inhalt speichern Problem!1.661KMX Racer Woh30.08.06 14:37
Re: ComboBox Inhalt speichern Problem!1.694viperbone30.08.06 15:49
Re: ComboBox Inhalt speichern Problem!1.780KMX Racer Woh30.08.06 16:11
Re: ComboBox Inhalt speichern Problem!1.757viperbone30.08.06 16:21
Re: ComboBox Inhalt speichern Problem!1.552KMX Racer Woh30.08.06 16:39
Re: ComboBox Inhalt speichern Problem!1.621Silver30.08.06 17:01
Re: ComboBox Inhalt speichern Problem!1.855viperbone30.08.06 18:50
Re: ComboBox Inhalt speichern Problem!1.657KMX Racer Woh31.08.06 08:20
Re: ComboBox Inhalt speichern Problem!1.632Silver31.08.06 18:53
Re: ComboBox Inhalt speichern Problem!1.652KMX Racer Woh01.09.06 08:58
Re: ComboBox Inhalt speichern Problem!1.710Silver01.09.06 15:11
Re: ComboBox Inhalt speichern Problem!1.684KMX Racer Woh01.09.06 15:51
Re: ComboBox Inhalt speichern Problem!1.628viperbone01.09.06 17:34
Re: ComboBox Inhalt speichern Problem!1.684viperbone01.09.06 17:43
Re: ComboBox Inhalt speichern Problem!1.702Silver01.09.06 18:33
Re: ComboBox Inhalt speichern Problem!1.633KMX Racer Woh04.09.06 08:37
Re: ComboBox Inhalt speichern Problem!1.655KMX Racer Woh04.09.06 08:52
Re: ComboBox Inhalt speichern Problem!1.659Chief04.09.06 08:58
Re: ComboBox Inhalt speichern Problem!1.755Silver04.09.06 11:19
Re: ComboBox Inhalt speichern1.722KMX Racer Woh30.08.06 10:30
Re: ComboBox Inhalt speichern1.714TiImann30.08.06 10:31
Re: ComboBox Inhalt speichern1.728DerLord30.08.06 21:37
Re: ComboBox Inhalt speichern1.596KMX Racer Woh31.08.06 14:53
Re: ComboBox Inhalt speichern1.693Silver31.08.06 18:54
Re: ComboBox Inhalt speichern1.731Chief01.09.06 11:42
Re: ComboBox Inhalt speichern1.805KMX Racer Woh01.09.06 12:02
Re: ComboBox Inhalt speichern- DIE LÖSUNG!1.767KMX Racer Woh04.09.06 09:25
Re: ComboBox Inhalt speichern- DIE LÖSUNG!2.272KMX Racer Woh04.09.06 09:30
Re: ComboBox Inhalt speichern-Neues kleine Problem1.718KMX Racer Woh07.09.06 08:36
Re: ComboBox Inhalt speichern-Neues kleine Problem- erledigt...1.626KMX Racer Woh07.09.06 11:42
Re: ComboBox Inhalt speichern-Neues kleine Problem- erledigt...1.695Chief19.09.06 23:40

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel