Je veux afficher une nouvelle ligne dans ma liste sur mon winform. J'ai un code comme celui-ci sur mon cours de revers.Comment insérer et afficher une nouvelle ligne dans le tableau de chaînes?
string[] a = new string[att]; //String array contains the attributes.
if (attCol != null)
for (int i = 0; i < att; i++) //Loop through entire attributes
{
a[i] = " Attribute name: " + attCol[i].Name + " , " + "Attribute value: " + attCol[i].Value; //Retrieving attribute name and values from the array.
}
return a; //returning the string array to be displayed in listbox
ici retourner une chaîne tableau [] sera retourné à la classe UI qui contient le code comme celui-ci
string[] attributecoll = new string[xNode.Attributes.Count]; //Declaration of String array where all the attributes of selected node are returned
attributecoll = classObj.selectedNode(xNode); //calling the selectedNode method from backend class and store it in a string array
foreach (string c in attributecoll)
{
listBox1.Items.Add(c); //adding the name and values of Attribute in the Listbox
}
Exemple pour l'élément de fichier xml
enter code here
<person name="John"/>
Cette affiche attribut nom et valeurs comme ceci dans la liste sur une seule ligne:
Nom d'attribut: Nom, Attribut Valeur: John
Mais je veux qu'il soit affiché comme celui-ci dans listboxas:
Attribut: Nom
Attribut Valeur: John
Pouvez-vous me dire où je vais mal? Merci pour votre aide ...
\ n ne fonctionne pas .... je ne peux pas utiliser vecteur/liste maintenant .. –
J'ai édité mon poste pour une solution – RvdK