Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#-如何确定表格';标题栏字体?_C#_Windows_Forms_Titlebar - Fatal编程技术网

C#-如何确定表格';标题栏字体?

C#-如何确定表格';标题栏字体?,c#,windows,forms,titlebar,C#,Windows,Forms,Titlebar,我想创建一个足够宽的表单来显示标题栏字符串,它是动态的。要计算字符串的文本宽度,我需要知道标题栏的字体。如何查询它?您可以使用属性: 获取用于在窗口标题栏中显示文本的字体 示例用法: using System.Drawing; var font = SystemFonts.CaptionFont; 您可以使用属性: 获取用于在窗口标题栏中显示文本的字体 示例用法: using System.Drawing; var font = SystemFonts.CaptionFont; 以下内容

我想创建一个足够宽的表单来显示标题栏字符串,它是动态的。要计算字符串的文本宽度,我需要知道标题栏的字体。如何查询它?

您可以使用属性:

获取用于在窗口标题栏中显示文本的字体

示例用法:

using System.Drawing;

var font = SystemFonts.CaptionFont;
您可以使用属性:

获取用于在窗口标题栏中显示文本的字体

示例用法:

using System.Drawing;

var font = SystemFonts.CaptionFont;

以下内容似乎与powershell等效:

function Get-CaptionFont {
    $font_family = ([Windows.SystemFonts]::"CaptionFontFamily").Source
    $font_size = [Windows.SystemFonts]::"CaptionFontSize"
    return New-Object System.Drawing.Font($font_family, $font_size, [System.Drawing.FontStyle]"Regular")
}

以下内容似乎与powershell等效:

function Get-CaptionFont {
    $font_family = ([Windows.SystemFonts]::"CaptionFontFamily").Source
    $font_size = [Windows.SystemFonts]::"CaptionFontSize"
    return New-Object System.Drawing.Font($font_family, $font_size, [System.Drawing.FontStyle]"Regular")
}