Soyez le premier à donner votre avis sur cette source.
Snippet vu 12 015 fois - Téléchargée 32 fois
using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; using System.Drawing.Text; namespace Crazyht.C.Windows.Forms { /// <summary> /// Combobox contenant les Fonts installé sur le système /// </summary> [ToolboxBitmap(typeof(Crazyht.C.Windows.Forms.ComboFont),"ComboFont.bmp")]public class ComboFont : System.Windows.Forms.ComboBox { public ComboFont () { InstalledFontCollection fonts =new System.Drawing.Text.InstalledFontCollection(); FontFamily [] fontfamill = fonts.Families; for (long i = fontfamill.GetLowerBound(0);i<=fontfamill.GetUpperBound(0);i++) this.Items.Add(fontfamill[i].Name); fontfamill = null; fonts = null; this.SelectedIndex = 0; } protected override void OnKeyPress (KeyPressEventArgs args) { Int32 key = Convert.ToInt32(args.KeyChar); if (!( (key == 13) || (key == 27) || (key==8))) { string sCherche = this.Text.ToLower(); foreach (Object obj in this.Items) { if ( obj.ToString().ToLower().StartsWith(sCherche)) { this.Text = obj.ToString(); this.SelectionStart = sCherche.Length; this.SelectionLength = obj.ToString().Length - sCherche.Length; this.SelectedItem = obj; args.Handled = true; break; } } } base.OnKeyPress(args); } } }
merci d'avance
votreComboBox.DataSource = (new InstalledFontCollection()).Families;
votreComboBox.DisplayMember = "Name";
Les objets Items que vous récupérez dans la Combo sont alors directement les objets Font.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.