MonthCalendar.TitleBackColor Özellik

Tanım

Takvimin başlık alanının arka plan rengini gösteren bir değeri alır veya ayarlar.

C#
public System.Drawing.Color TitleBackColor { get; set; }

Özellik Değeri

Bir Color. Varsayılan, etkin açıklamalı alt yazılar için sistem rengidir.

Özel durumlar

Değer geçerli Colorbir değil.

Örnekler

Aşağıdaki kod örneği, bir takvim yılı görüntüleyen bir MonthCalendar denetim içeren formu görüntüler. Örnekte, takvim denetiminin BackColorgörünümünü özelleştirmek için , ForeColorTitleBackColor, TitleForeColorCalendarDimensionsve TrailingForeColor özelliklerini ayarlama gösterilmektedir. , BoldedDatesve MonthlyBoldedDates gibi AnnuallyBoldedDatesdiğer özellikler, hangi tarihlerin kalın olduğunu özelleştirmek için ayarlanır. Örnek ayrıca takvim biçimini değiştirmek için , , ve MaxSelectionCount özelliklerini ayarlarFirstDayOfWeek. MinDateMaxDate DateSelected ve DateChanged olayları da işlenir ve durumları formda görüntülenir.

C#
using System;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
{
    private System.Windows.Forms.MonthCalendar monthCalendar1;
    private System.Windows.Forms.TextBox textBox1;

    [STAThread]
    static void Main() 
    {
        Application.Run(new Form1());
    }

    public Form1()
    {
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
        this.textBox1.Location = new System.Drawing.Point(48, 488);
        this.textBox1.Multiline = true;
        this.textBox1.ReadOnly = true;
        this.textBox1.Size = new System.Drawing.Size(824, 32);

        // Create the calendar.
        this.monthCalendar1 = new System.Windows.Forms.MonthCalendar();

        // Set the calendar location.
        this.monthCalendar1.Location = new System.Drawing.Point(47, 16);

        // Change the color.
        this.monthCalendar1.BackColor = System.Drawing.SystemColors.Info;
        this.monthCalendar1.ForeColor = System.Drawing.Color.FromArgb(
                                 ((System.Byte)(192)), ((System.Byte)(0)), ((System.Byte)(192)));
        this.monthCalendar1.TitleBackColor = System.Drawing.Color.Purple;
        this.monthCalendar1.TitleForeColor = System.Drawing.Color.Yellow;
        this.monthCalendar1.TrailingForeColor = System.Drawing.Color.FromArgb(
                                 ((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(0)));

        // Add dates to the AnnuallyBoldedDates array.
        this.monthCalendar1.AnnuallyBoldedDates = 
            new System.DateTime[] { new System.DateTime(2002, 4, 20, 0, 0, 0, 0),
                                    new System.DateTime(2002, 4, 28, 0, 0, 0, 0),
                                    new System.DateTime(2002, 5, 5, 0, 0, 0, 0),
                                    new System.DateTime(2002, 7, 4, 0, 0, 0, 0),
                                    new System.DateTime(2002, 12, 15, 0, 0, 0, 0),
                                    new System.DateTime(2002, 12, 18, 0, 0, 0, 0)};

        // Add dates to BoldedDates array.
        this.monthCalendar1.BoldedDates = new System.DateTime[] {new System.DateTime(2002, 9, 26, 0, 0, 0, 0)};

        // Add dates to MonthlyBoldedDates array.
        this.monthCalendar1.MonthlyBoldedDates = 
           new System.DateTime[] {new System.DateTime(2002, 1, 15, 0, 0, 0, 0),
                                  new System.DateTime(2002, 1, 30, 0, 0, 0, 0)};

        // Configure the calendar to display 3 rows by 4 columns of months.
        this.monthCalendar1.CalendarDimensions = new System.Drawing.Size(4, 3);

        // Set week to begin on Monday.
        this.monthCalendar1.FirstDayOfWeek = System.Windows.Forms.Day.Monday;

        // Set the maximum visible date on the calendar to 12/31/2010.
        this.monthCalendar1.MaxDate = new System.DateTime(2010, 12, 31, 0, 0, 0, 0);

        // Set the minimum visible date on calendar to 12/31/2010.
        this.monthCalendar1.MinDate = new System.DateTime(1999, 1, 1, 0, 0, 0, 0);

        // Only allow 21 days to be selected at the same time.
        this.monthCalendar1.MaxSelectionCount = 21;

        // Set the calendar to move one month at a time when navigating using the arrows.
        this.monthCalendar1.ScrollChange = 1;

        // Do not show the "Today" banner.
        this.monthCalendar1.ShowToday = false;

        // Do not circle today's date.
        this.monthCalendar1.ShowTodayCircle = false;
            
        // Show the week numbers to the left of each week.
        this.monthCalendar1.ShowWeekNumbers = true;

        // Add event handlers for the DateSelected and DateChanged events
        this.monthCalendar1.DateSelected += new System.Windows.Forms.DateRangeEventHandler(this.monthCalendar1_DateSelected);
        this.monthCalendar1.DateChanged += new System.Windows.Forms.DateRangeEventHandler(this.monthCalendar1_DateChanged);

        // Set up how the form should be displayed and add the controls to the form.
        this.ClientSize = new System.Drawing.Size(920, 566);
        this.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox1, this.monthCalendar1});
        this.Text = "Month Calendar Example";
    }

    private void monthCalendar1_DateSelected(object sender, System.Windows.Forms.DateRangeEventArgs e)
    {
        // Show the start and end dates in the text box.
        this.textBox1.Text = "Date Selected: Start = " +
            e.Start.ToShortDateString() + " : End = " + e.End.ToShortDateString();
    }

    private void monthCalendar1_DateChanged(object sender, System.Windows.Forms.DateRangeEventArgs e)
    {
        // Show the start and end dates in the text box.
        this.textBox1.Text = "Date Changed: Start =  " +
            e.Start.ToShortDateString() + " : End = " + e.End.ToShortDateString();
    }
}

Açıklamalar

Haftanın günleri metninin yazı tipi rengi özelliğine TitleBackColor bağlıdır. Takvimin TitleBackColor ana görüntüleme alanının değerine eşit BackColor olarak ayarlanması, haftanın günleri metninin okunamaz hale gelmesine neden olur.

Windows Vista'dan başlayarak ve temaya bağlı olarak, bu özelliğin ayarlanması takvimin görünümünü değiştirmeyebilir. Örneğin, Windows Aero temasını kullanacak şekilde ayarlandıysa, bu özelliğin ayarlanmasının hiçbir etkisi olmaz. Bunun nedeni, takvimin güncelleştirilmiş bir sürümünün geçerli işletim sistemi temasından çalışma zamanında türetilen bir görünümle işlenmesidir. Bu özelliği kullanmak ve takvimin önceki sürümünü etkinleştirmek istiyorsanız, uygulamanız için görsel stilleri devre dışı bırakabilirsiniz. Görsel stilleri devre dışı bırakmak, uygulamanızdaki diğer denetimlerin görünümünü ve davranışını etkileyebilir. Visual Basic'te görsel stilleri devre dışı bırakmak için Project Tasarım Aracı açın ve XP görsel stillerini etkinleştir onay kutusunun işaretini kaldırın. C# dilinde görsel stilleri devre dışı bırakmak için Program.cs dosyasını açın ve açıklama satırı yapın Application.EnableVisualStyles();.

Şunlara uygulanır

Ürün Sürümler
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10