Accueil > > > COMBOBOX DE SELECTION D'UNE POLICE
COMBOBOX DE SELECTION D'UNE POLICE
Information sur la source
Description
Coller le code suivant dans un fichier de classe, il ne vous plus qu'a l'utiliser comme une combobox :)
Source
- 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);
- }
- }
- }
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
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
combobox [ par jdaviaud ]
J'aurais voulu savoir comment déterminer si aucune valeur n'a été sélectionnée dans un combobox.j'ai essayé if(MonCombo.SelectedItem.ToString() == "")
Liste de police dans un combo [ par sebastiencarrer ]
Comment creer un combobox qui m affiche la liste des polices disponibles?Seb
probleme de combobox en VB [ par jogaloula ]
> J'aurais voulu savoir comment déterminer si aucune valeur n'a été sélectionnée dans un combobox de style 2 dropdown> > MERKIII
ajout d un combobox dans un dataform [ par nicolasgib ]
BonjourJe suis tout debutant en prog j ai reussi a me faire une petite aplication pour un fichier client avec dataform en C# et une base access je vou
ComboBox [ par Online ]
SalutVoila, je voudrais attribuer une action à chaque item d'une comboBox, j'ai beau chercher, je ne trouve pas, quelqu'un aurait un conseil pour moi?
Utilisation de contrôles (listbox,combobox, datagrid,etc) [ par floben21 ]
Bonjours à tous,En fait j'aurais tout d'abord besoin de savoir comment retirer un item d'une listbox,l'ajout se fesant à l'aide de Listbox1.Items.add(
Combobox - AutoComplete [ par Tommy666 ]
Bonjour, je voulais savoir comment faire pour avoir une proposition des mots (saisie automatique) lorsque je tape la (ou les) première lettre dans une
ajouter une police a un projet VS [ par d0d0 ]
Bonsoir.je cherche a ajouter une police de caractère à un projet Visual Studio.MerciD0D0
ComboBox [ par SebSharp ]
Salut a tous,Est ce qu'il est possible en C# pour un comboBox de ne pas limiter la vue du contenu si la taille du comboBox est plus petit que le texte
couper le lien entre dataset et combobox pour vider la liste déroulante [ par xerque ]
Bonjour,Mon problème provient du fait que j'arrive pas à vider la liste qui se déroule d'un comboBox. Je m'explique : le comboBox est alimenté pas un
|
Derniers Blogs
[TECHDAYS2012] OUI J'Y SERAI![TECHDAYS2012] OUI J'Y SERAI! par JeremyJeanson
Bonsoir, Certes, je l'annonce avec un peu de retard, mais je serai effectivement au Techdays demain. Comme l'an dernier, je participerai au programme ATE (Ask The Expert). Si vous avez des questions Workflow, WCF, AppFabric ou plus généralement .net, n'hé...
Cliquez pour lire la suite de l'article par JeremyJeanson TFS INTEGRATION TOOLS - SUIVI DES SYNCHRONISATIONS AVEC REPORTING SERVICESTFS INTEGRATION TOOLS - SUIVI DES SYNCHRONISATIONS AVEC REPORTING SERVICES par vfabing
Afin de s'assurer du bon fonctionnement des différentes synchronisations effectuées par les TFS Integration Tools, 2 rapports sont présents dès l'installation. Il suffit alors d'effectuer les manipulations suivantes pour pouvoir les visualiser : Loca...
Cliquez pour lire la suite de l'article par vfabing CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|