当我尝试在记事本中实现字体菜单项时,我没有更改文本,我的代码中是否有任何错误
这是我的代码
private void fontMenuItem_Click(object sender, EventArgs e)
{
FontDialog objFontForm = new FontDialog();
objFontForm.ShowDialog();
}
//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;
}