j'espère qu'elle n'est pas cassée
Public Class Form1 Dim MySource As New AutoCompleteStringCollection() Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dim Str(0) As String For Each Ligne In MySource Str(Str.GetUpperBound(0)) = Ligne ReDim Preserve Str(Str.GetUpperBound(0) + 1) Next System.IO.File.WriteAllLines("c:\users" & Environment.UserName.ToString & "\desktop\AutoCompleteSource.txt", Str) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim Str() As String = System.IO.File.ReadAllLines("c:\users" & Environment.UserName.ToString & "\desktop\AutoCompleteSource.txt") For Each Ligne In Str MySource.Add(Ligne.ToString) Next TextBox1.AutoCompleteCustomSource = MySource Catch ex As Exception End Try TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest End Sub Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyCode = Keys.Enter Then MySource.Add(TextBox1.Text) TextBox1.AutoCompleteCustomSource = MySource TextBox1.Clear() End If End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub End Class
la source est tout ce qui est déjà tappé dans ce champ
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Class Form1 Dim MySource As New AutoCompleteStringCollection() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest End Sub Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyCode = Keys.Enter Then MySource.Add(TextBox1.Text) TextBox1.AutoCompleteCustomSource = MySource End If TextBox1.Clear() End Sub End Class
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyCode = Keys.Enter Then MySource.Add(TextBox1.Text) TextBox1.AutoCompleteCustomSource = MySource TextBox1.Clear() End If
Public Class Form1 Dim MySource As New AutoCompleteStringCollection() Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dim Str(0) As String For Each Ligne In MySource Str(Str.GetUpperBound(0)) = Ligne ReDim Preserve Str(Str.GetUpperBound(0) + 1) Next My.Settings.AutoCompListe = String.Join(";", Str) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Str() As String Str = My.Settings.AutoCompListe.Split(";") For Each Mot In Str MySource.Add(Mot) Next TextBox1.AutoCompleteCustomSource = MySource TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest End Sub Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyCode = Keys.Enter Then MySource.Add(TextBox1.Text) TextBox1.AutoCompleteCustomSource = MySource TextBox1.Clear() End If End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub End Class
mais je sais pas comment faire avec un fichier,