begin process at 2012 02 07 08:54:54
  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 :10 207

Auteur : Crazyht

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (3)
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 Source avec une capture Source .NET (Dotnet) ORIONBANQUE par toutphp
Source avec Zip Source avec une capture Source .NET (Dotnet) ORIONAPPLICATION par toutphp
Source avec Zip SOCKET CONNEXION CLIENT & SERVEUR par ziedto83
Source avec Zip Source .NET (Dotnet) FFMPEG.NET : WRAPPER .NET DE FFMPEG par MasterShadows
Source avec Zip Source .NET (Dotnet) ATTACHER, CRÉER ET SAUVEGARDER UNE BASE DE DONNÉES SQL SERVE... par Alvepinai

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture FAIRE AVANCER UNE PROGRESSBAR EN FONCTION D'UN NOMBRE DE COM... par guiguizeitzt
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 .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 :(

Commentaire de davedave44 le 28/06/2010 09:51:38

Bonjours j'aimerais savoir comment ensuite attribué le chois de la police comme police du richTextBox et comment créer ensuite un comboBox avec les taille de la police choisis, car les polices n'utilise pas toutes les même taille7
merci d'avance

 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 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
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 : 1,966 sec (4)

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