Pas d'erreur, mais lors du débug : L'exception NullReferenceException n'a pas été gérée - La référence d'objet n'est pas définie à une instance d'un objet.
fontfamill = null;forcément il n'est plus définit.
for (long i = fontfamill.GetLowerBound(0); i <= fontfamill.GetUpperBound(0); i++)par un ForEach qui t'évite GetLowerBound(0) et GetUpperBound(0) mais c'est comme tu préfères.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Visualisation { public partial class frmVisu : Form { #region Déclarations //ici tu déclares toutes les variables dont la portée est le formulaire //pour "voir" la portée d'une variable, il suffit de chercher le couple de {} qui l'encadre. //donc ce que tu déclares ici est valable pour tout "partial class frmVisu" int toto; string tata = "tata";// tu peux initialiser la variable ou non (dans certains cas ce n'est pas possible) //c'est là que je déclarerais FontFamily[] FontFamily[] fontfamill; #endregion #region Initilisation public frmVisu() { InitializeComponent(); } private void frmVisu_Load(object sender, EventArgs e) { ChargeMesFont();//voir en dessous lsbPolice.SelectedIndex = 0; lblVisu.Text = "Voici le résultat"; } private void ChargeMesFont()//te permets si besoin de refaire le chargement { System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection(); FontFamily[] fontfamill = fonts.Families; for (long i = fontfamill.GetLowerBound(0); i <= fontfamill.GetUpperBound(0); i++) lsbPolice.Items.Add(fontfamill[i].Name); //fontfamill = null; Surtout pas si tu veux t'en resservir fonts = null; } #endregion #region IHM private void btValider_Click(object sender, EventArgs e) { .... } private void btSupprimer_Click(object sender, EventArgs e) { .... } private void btQuitter_Click(object sender, EventArgs e) { Close(); } private void btAffiche_Click(object sender, EventArgs e) { .... } #endregion } }