penchu
Messages postés167Date d'inscriptionmercredi 11 février 2004StatutMembreDernière intervention 5 janvier 2006
-
21 déc. 2004 à 14:23
penchu
Messages postés167Date d'inscriptionmercredi 11 février 2004StatutMembreDernière intervention 5 janvier 2006
-
21 déc. 2004 à 15:11
dans ma form, g une combobox et une textbox.
dans la combo, j'ai mis un code qui reprend la liste de toutes les fonts installées sur ma machine.
Comment peut-on faire pour assigner une font a une textbox?
J'ai essayé la facon suivante :
this.textBox1.font=this.combobox1.selectedindex;
voici mon code en fait (ce n'est qu'un test, c'est pour intégrer ca dans un autre programme)
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Text;
namespace WindowsApplication14
{
/// <summary>
/// Description résumée de Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox comboBox1;
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();
InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
FontFamily [] fontfamille = fonts.Families;
for (long i = fontfamille.GetLowerBound(0);i<=fontfamille.GetUpperBound(0);i++)
{
this.comboBox1.Items.Add(fontfamille[i].Name);
}