Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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
如何仅在MonthCalendar标题标题上显示月份?c#_C#_Winforms - Fatal编程技术网

如何仅在MonthCalendar标题标题上显示月份?c#

如何仅在MonthCalendar标题标题上显示月份?c#,c#,winforms,C#,Winforms,我只需要在MonthCalendar标题上显示月份名称 我查看了MonthCalendar方法,但没有自定义标题或更改标题的方法。只能更改字体颜色。通过使用 屏幕副本(法文) 测试代码(Windows 10上的C#/Winforms/VS 2015) (我在评论中添加了要添加的参考) private System.Windows.Forms.TextBox textBox1; private System.Windows.Controls.Calendar日历1; 私有void For

我只需要在MonthCalendar标题上显示月份名称


我查看了MonthCalendar方法,但没有自定义标题或更改标题的方法。只能更改字体颜色。

通过使用

  • 屏幕副本(法文)

  • 测试代码(Windows 10上的C#/Winforms/VS 2015)
(我在评论中添加了要添加的参考)

private System.Windows.Forms.TextBox textBox1;
private System.Windows.Controls.Calendar日历1;
私有void Form1\u加载(对象发送方、事件参数e)
{
//添加对PresentationFramework的引用
calendar1=新的System.Windows.Controls.Calendar();
//测试背景
//添加对PresentationCore的引用
//添加对WindowsBase的引用
System.Windows.Media.LinearGradientBrush LinearGradientBrush=新建System.Windows.Media.LinearGradientBrush(System.Windows.Media.Colors.Cyn、System.Windows.Media.Colors.Blue、new System.Windows.Point(0,0)、new System.Windows.Point(0,1));
calendar1.Background=linearGradientBrush;
//日历容器
System.Windows.Controls.Canvas Canvas=新的System.Windows.Controls.Canvas();
System.Windows.Controls.Viewbox viewbox1=新的System.Windows.Controls.Viewbox();
viewbox1.StretchDirection=System.Windows.Controls.StretchDirection.Both;
viewbox1.Stretch=System.Windows.Media.Stretch.Fill;
viewbox1.MaxWidth=260;
viewbox1.MaxHeight=260;
viewbox1.Child=calendar1;
canvas.Children.Add(viewbox1);
//测试事件
calendar1.SelectedDatesChanged+=calendar1\u SelectedDatesChanged;
textBox1=new System.Windows.Forms.TextBox();
textBox1.位置=新系统.图纸.点(10280);
textBox1.Name=“textBox1”;
textBox1.Size=新系统.图纸.尺寸(149,20);
控件。添加(textBox1);
//测试新文化
//利用制度全球化;
CultureInfo CultureInfo=(CultureInfo.CurrentCulture.Clone()作为CultureInfo);
cultureinfo.DateTimeFormat.YearMonthPattern=@“yyyy-MMMM”;
//cultureinfo.DateTimeFormat.YearMonthPattern=@“MMMM”;
System.Threading.Thread.CurrentThread.CurrentCulture=cultureinfo;
//控件的主机
//添加对WindowsFormsIntegration的引用
//使用System.Windows.Forms.Integration;
var elementHost=new elementHost();
elementHost.Child=canvas;
控件。添加(elementHost);
elementHost.Location=新系统图点(10,10);
elementHost.Size=新系统.图纸.尺寸(300300);
ClientSize=新系统图纸尺寸(280340);
CenterToScreen();
}
私有无效日历1\u SelectedDatesChanged(对象发送者,System.Windows.Controls.SelectionChangedEventArgs e)
{
textBox1.Text=calendar1.SelectedDate.ToString();
}

来自注释,一种使用

  • 屏幕副本(法文)

  • 测试代码(Windows 10上的C#/Winforms/VS 2015)
(我在评论中添加了要添加的参考)

private System.Windows.Forms.TextBox textBox1;
private System.Windows.Controls.Calendar日历1;
私有void Form1\u加载(对象发送方、事件参数e)
{
//添加对PresentationFramework的引用
calendar1=新的System.Windows.Controls.Calendar();
//测试背景
//添加对PresentationCore的引用
//添加对WindowsBase的引用
System.Windows.Media.LinearGradientBrush LinearGradientBrush=新建System.Windows.Media.LinearGradientBrush(System.Windows.Media.Colors.Cyn、System.Windows.Media.Colors.Blue、new System.Windows.Point(0,0)、new System.Windows.Point(0,1));
calendar1.Background=linearGradientBrush;
//日历容器
System.Windows.Controls.Canvas Canvas=新的System.Windows.Controls.Canvas();
System.Windows.Controls.Viewbox viewbox1=新的System.Windows.Controls.Viewbox();
viewbox1.StretchDirection=System.Windows.Controls.StretchDirection.Both;
viewbox1.Stretch=System.Windows.Media.Stretch.Fill;
viewbox1.MaxWidth=260;
viewbox1.MaxHeight=260;
viewbox1.Child=calendar1;
canvas.Children.Add(viewbox1);
//测试事件
calendar1.SelectedDatesChanged+=calendar1\u SelectedDatesChanged;
textBox1=new System.Windows.Forms.TextBox();
textBox1.位置=新系统.图纸.点(10280);
textBox1.Name=“textBox1”;
textBox1.Size=新系统.图纸.尺寸(149,20);
控件。添加(textBox1);
//测试新文化
//利用制度全球化;
CultureInfo CultureInfo=(CultureInfo.CurrentCulture.Clone()作为CultureInfo);
cultureinfo.DateTimeFormat.YearMonthPattern=@“yyyy-MMMM”;
//cultureinfo.DateTimeFormat.YearMonthPattern=@“MMMM”;
System.Threading.Thread.CurrentThread.CurrentCulture=cultureinfo;
//控件的主机
//添加对WindowsFormsIntegration的引用
//使用System.Windows.Forms.Integration;
var elementHost=new elementHost();
elementHost.Child=canvas;
控件。添加(elementHost);
elementHost.Location=新系统图点(10,10);
elementHost.Size=新系统.图纸.尺寸(300300);
ClientSize=新系统图纸尺寸(280340);
CenterToScreen();