-2

当我尝试在记事本中实现字体菜单项时,我没有更改文本,我的代码中是否有任何错误

这是我的代码

private void fontMenuItem_Click(object sender, EventArgs e)
{
    FontDialog objFontForm = new FontDialog();
    objFontForm.ShowDialog();

}
4

1 回答 1

3

这是取自DotNetPearls的一个非常简单的示例

//Create FontDialog instance
FontDialog fontDialog1 = new FontDialog();
// Show the dialog.
DialogResult result = fontDialog1.ShowDialog();
// See if OK was pressed.
if (result == DialogResult.OK)
{
    // Get Font.
    Font font = fontDialog1.Font;
    // Set TextBox properties.
    this.textBox1.Text = string.Format("Font is: {0}", font.Name);
    this.textBox1.Font = font;
}
于 2012-09-25T07:46:08.843 回答