godefrw
Messages postés56Date d'inscriptionlundi 13 septembre 2004StatutMembreDernière intervention20 mars 2006
-
7 oct. 2004 à 16:03
godefrw
Messages postés56Date d'inscriptionlundi 13 septembre 2004StatutMembreDernière intervention20 mars 2006
-
8 oct. 2004 à 18:01
Je ne me suis jamais servi de cet élément auparavant. Donc j'ai du commettre une erreur. J'ai copier coller le code de la doc de visual studio et ça ne marche pas du tout:
J'ai créer un Error provider et une textBox
protected void textBox1_Validating (object sender,
System.ComponentModel.CancelEventArgs e)
{
try
{
int x = Int32.Parse(textBox1.Text);
errorProvider1.SetError(textBox1, "");
}
catch (Exception f)
{
errorProvider1.SetError(textBox1, "Not an integer value.");
}
}
Lorsque je rentre un mot je n'obtient aucun message d'erreur. Est ce normal?
godefrw
Messages postés56Date d'inscriptionlundi 13 septembre 2004StatutMembreDernière intervention20 mars 2006 8 oct. 2004 à 10:10
Mon évènement textBox1_validating est bien rataché à ma textBox avec la ligne de code que tu m'as données.
Je n'ai que ce code là rien de plus...
Peut-être une propriété de mon errorprovider n'est pas bien intitialisée?
Ced
Vous n’avez pas trouvé la réponse que vous recherchez ?
godefrw
Messages postés56Date d'inscriptionlundi 13 septembre 2004StatutMembreDernière intervention20 mars 2006 8 oct. 2004 à 17:36
Voilà le code de mon application: désolé si c'est un peu long.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Xml;
if ( Folder1.ShowDialog() == DialogResult.OK )
{
//affichage dans la textBox
emplacement.Text = Folder1.SelectedPath;
//sauvegarde des donnéees dans les attributs de la fenêtre
nom_chemin = Folder1.SelectedPath;
}
}
public string get_chemin()
{
return nom_chemin;
}
public string get_nom_projet()
{
return nom_projet;
}
public string get_fichier_xml()
{
return nom_fichier_xml;
}
public void button2_Click(object sender, System.EventArgs e)
{
if(nom.Text != "")
{
nom_projet = nom.Text;
//creation du repertoire Oasis
mon_rep = new DirectoryInfo(String.Concat(nom_chemin, @"", nom_projet));
mon_rep.Create();
// creation du fichier xml
nom_fichier_xml = String.Concat(nom_chemin, @"/", nom_projet, @"/annotations.xml");
XmlTextWriter tr = new XmlTextWriter(nom_fichier_xml, null);
tr.Formatting = Formatting.Indented;
tr.Flush();
tr.Close();
this.DialogResult = DialogResult.OK;
}
}
protected void nom_Validating (object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
int x = Int32.Parse(nom.Text);
errorProvider1.SetError(this.nom, "");
}
catch (Exception f)
{
errorProvider1.SetError(this.nom, "Not an integer value.");
}
}
}
}