Configuración de la fuente del cuadro de texto desde el código detrás


Esta puede ser una pregunta estúpida, pero ¿cómo puedo establecer la fuente de a TextBox desde a string en el código detrás?

// example
txtEditor.FontFamily = "Consolas";
Author: Jiew Meng, 2010-10-23

6 answers

txtEditor.FontFamily = new FontFamily("Consolas"); // the Media namespace
 51
Author: Gishu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-23 03:32:17

Utilice la siguiente sintaxis:

lblCounting.Font  = new Font("Times New Roman", 50);

Donde lblCounting es cualquier etiqueta.

 16
Author: Furqan Ahmed,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-11-08 18:23:32
System.Drawing.Font = new Font("Arial", 8, FontStyle.Bold);
 6
Author: Amir Nazari,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-10 20:05:39

Una forma sencilla de hacerlo globalmente, programáticamente:

public MainWindow()
{
    this.FontFamily = new FontFamily("Segoe UI");
}
 3
Author: Strong,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-14 15:29:21

Copie y pegue su código de ejemplo en el constructor del formulario, justo después de InitializeComponent();

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        txtEditor.FontFamily = new FontFamily("Consolas");
    }
}
 2
Author: Merlyn Morgan-Graham,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-23 03:33:23

Uso txtEditor.Font.Name = "Consolas";

 2
Author: Rahul Soni,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-23 03:39:49