begin process at 2010 02 10 06:10:02
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

.NET

 > COMBOBOX DE SELECTION D'UNE POLICE

COMBOBOX DE SELECTION D'UNE POLICE


 Information sur la source

Note :
6 / 10 - par 2 personnes
6,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :.NET Source .NET ( DotNet ) Classé sous :police, combobox Niveau :Débutant Date de création :05/05/2003 Date de mise à jour :05/05/2003 15:50:35 Vu :8 098

Auteur : Crazyht

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note


 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

Source avec Zip Source .NET (Dotnet) BRIQUE DE LOG
Source avec Zip Source .NET (Dotnet) ACCÉS A DES PARTAGES RÉSEAUX AVEC UN LOGIN/PWD
Source avec Zip Source .NET (Dotnet) DPAPI : PROTECTION DES DONNÉES PAR UTILISATEUR OU MACHINE
Source avec Zip Source .NET (Dotnet) IPBOX : SAISIE D'ADRESSE IP
Source avec Zip Source .NET (Dotnet) FONTCOMBOBOX : COMBO DE SELECTION DE LA FONT

 Sources de la même categorie

Source avec Zip CHAT SERVER-CLIENT par abderrahmenbilog
Source avec Zip Source avec une capture Source .NET (Dotnet) SIMULATION DE CONSOLE POUR WINDOWS MOBILE par originalcompo
Source avec Zip Source .NET (Dotnet) BASE DE DONNÉES EN XML par DanMor498
Source avec Zip Source avec une capture Source .NET (Dotnet) SIMPLECONV - APPLICATION DE CONVERSION MONÉTAIRE AVEC TAUX E... par Jeffrey_
Source avec Zip Source .NET (Dotnet) TRAITEUR D'IMAGE (MINI) par ycyril

 Sources en rapport avec celle ci

Source avec une capture TOOLTIP TEXT POUR LA LISTE DÉROULANTE D'UN COMBOBOX par whismeril
Source avec Zip Source avec une capture Source .NET (Dotnet) COLORCOMBOBOX, COMBO BOX PERMETTANT DE SÉLECTIONNER DES COUL... par manshivas
Source avec Zip Source avec une capture Source .NET (Dotnet) [.NET 2.0 ] PERSONNALISER LES COLONNES D'UN DATAGRIDVIEW par romagny13
Source avec Zip Source avec une capture Source .NET (Dotnet) TEXTBOX AVEC LABEL INCORPORÉ par witre
Source avec Zip Source .NET (Dotnet) FONTCOMBOBOX : COMBO DE SELECTION DE LA FONT par Crazyht

Commentaires et avis

Commentaire de Schad le 15/05/2003 09:02:17

Autre moyen de récupérer les polices installées dans un ComboBox:

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.

Commentaire de Crazyht le 15/05/2003 12:12:35 administrateur CS

Ouep mais j'aime pas utiliser DataSource :) Surement des reste de VB6 :(

 Ajouter un commentaire


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 ] &gt; J'aurais voulu savoir comment déterminer si aucune valeur n'a été sélectionnée dans un combobox de style 2 dropdown&gt; &gt; 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


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,780 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales