|
|
|
|
Bonjour à vous tous
Après avoir répondu pendant quelques semaines aux internautes dans différents forums de CCM, c'est à mon tour d'avoir besoin de votre aide.
En effet, je programme en C# une petite application qui fait des requêtes sur une base de données.
J'ai une fenêtre avec deux TextBox. Le premier a l'autocomplétion (suggestion lors de la frappe) d'activé, le second nom.
Or le second fait planté de temps en temps le programme avec l'exception suivante :
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
La localisation de l'exception (en gras):
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
this.textBox2.AutoCompleteSource = AutoCompleteSource.CustomSource; this.textBox2.AutoCompleteMode = AutoCompleteMode.Suggest; this.textBox2.AutoCompleteCustomSource.Clear(); this.textBox2.AutoCompleteCustomSource.AddRange(Remplir_Noms_Proposes());
if (e.KeyChar == (char)Keys.Enter)
Console.WriteLine("Touche ENTER pressée");
else
Console.WriteLine("autre caractère pressé");
Configuration: Windows XP Internet Explorer 7.0
Rebonjour
// // textBox2 // this.textBox2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.textBox2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource; this.textBox2.AutoCompleteCustomSource.AddRange(Remplir_Noms_Proposes()); this.textBox2.Location = new System.Drawing.Point(15, 74); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(100, 20); this.textBox2.TabIndex = 3; this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
Console.WriteLine("***APPEL textboxkeypress***");
if (e.KeyChar == (char)Keys.Enter)
Console.WriteLine("Touche ENTER pressée");
else if (e.KeyChar == (char)Keys.Space)
Console.WriteLine("Barre d'espace pressée");
else
Console.WriteLine("autre caractère pressé");
}
Si j'appuie sur Espace : ca affiche bien Barre d'espace pressée Si j'appuie sur Enter, cela n'appelle même pas KeyPress (pas d'affichage de ***APPEL textboxkeypress***) Si j'appuie sur Backspace il affiche bien autre caractère pressé De plus, en tappant une lettre dans mon textBox, il affiche bien autre caractère pressé dans la console. Quelqu'un aurait une idée de comment pouvior gérer le Enter. En effet, j'aimerai qu'il me propose un nom de client et j'appuie sur Enter et cela m'ouvre une fenêtre avec les infos détaillés du client (adresses, ...) Merci beaucoup de votre aide. Bonne journée pti_jul |