代码编译时没有异常 但是运行时却得不到编译想要的结果

代码编译时没有错误 但是运行时却得不到编译想要的结果


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace _1._1._1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            fontDialog1.ShowColor = true;
            if (fontDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                dateTimePicker1.CalendarFont = fontDialog1.Font;
            }
        }



代码编译时没有异常 但是运行时却得不到编译想要的结果

这是程序界面,目的是点击calendrefont, 改变日历里的字体





------解决思路----------------------
dateTimePicker1.CalendarFont = fontDialog1.Font;
换成
dateTimePicker1.Font = fontDialog1.Font;