Coller le code suivant dans un fichier de classe, il ne vous plus qu'a l'utiliser comme une combobox :)
Source / Exemple :
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);
}
}
}
Conclusion :
Bonne prog
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.