Advertisement
Fhernd

Principal.cs

Mar 7th, 2018
1,498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Text;
  4. using System.Windows.Forms;
  5.  
  6. namespace R801FuentesInstaladas
  7. {
  8.     public partial class Principal : Form
  9.     {
  10.         public Principal()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.         protected override void OnLoad(EventArgs e)
  16.         {
  17.             base.OnLoad(e);
  18.  
  19.             using (InstalledFontCollection familiaFuentes = new InstalledFontCollection())
  20.             {
  21.                 int margenSuperior = 10;
  22.  
  23.                 foreach (FontFamily familia in familiaFuentes.Families)
  24.                 {
  25.                     try
  26.                     {
  27.                         Label lblFuente = new Label();
  28.                         lblFuente.Text = familia.Name;
  29.                         lblFuente.Font = new Font(familia, 14);
  30.                         lblFuente.Left = 10;
  31.                         lblFuente.Width = pnlFuentes.Width;
  32.                         lblFuente.Top = margenSuperior;
  33.  
  34.                         pnlFuentes.Controls.Add(lblFuente);
  35.  
  36.                         margenSuperior += 30;
  37.                     }
  38.                     catch (Exception exception)
  39.                     {
  40.                         Console.WriteLine(exception);
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement