月間予定表に太字で表示される日付を追加します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
'宣言
Public Sub AddBoldedDate ( _
date As DateTime _
)
'使用
Dim instance As MonthCalendar
Dim date As DateTime
instance.AddBoldedDate(date)
public void AddBoldedDate (
DateTime date
)
public:
void AddBoldedDate (
DateTime date
)
public void AddBoldedDate (
DateTime date
)
public function AddBoldedDate (
date : DateTime
)
パラメータ
- date
太字で表示される日付。
解説
表示を更新するために、後で UpdateBoldedDates メソッドを呼び出す必要があります。
複数の日付を 1 回の割り当てによって追加するために、DateTime オブジェクトの配列を BoldedDates プロパティに割り当てることができます。
使用例
AddBoldedDate メソッドおよび UpdateBoldedDates メソッドを使用して、ファイルから読み取った日付をマークし、太字フォントで表示するコード例を次に示します。この例では、monthCalendar1
という名前の MonthCalendar コントロールが Form に追加されており、このメソッドがそのフォーム内に含まれ、そこから呼び出される必要があります。
' The following method uses Add to add dates that are
' bolded, followed by an UpdateBoldedDates to make the
' added dates visible.
Private Sub loadDates()
Dim myInput As [String]
Try
Dim myInputStream As StreamReader = File.OpenText("myDates.txt")
myInput = myInputStream.ReadLine()
While Not myInput Is Nothing
monthCalendar1.AddBoldedDate(DateTime.Parse(myInput.Substring(0, myInput.IndexOf(" "))))
listBox1.Items.Add(myInput)
myInput = myInputStream.ReadLine()
End While
monthCalendar1.UpdateBoldedDates()
myInputStream.Close()
File.Delete("myDates.txt")
Catch fnfe As FileNotFoundException
End Try
End Sub 'loadDates
// The following method uses Add to add dates that are
// bolded, followed by an UpdateBoldedDates to make the
// added dates visible.
private void loadDates()
{
String myInput ;
try
{
StreamReader myInputStream = File.OpenText("myDates.txt");
while((myInput = myInputStream.ReadLine()) != null)
{
monthCalendar1.AddBoldedDate(DateTime.Parse(myInput.Substring(0,myInput.IndexOf(" "))));
listBox1.Items.Add(myInput);
}
monthCalendar1.UpdateBoldedDates();
myInputStream.Close();
File.Delete("myDates.txt");
}catch(FileNotFoundException fnfe)
{
// Code to handle a file that could not be found should go here.
Console.WriteLine("An error occurred: '{0}'", fnfe);
}
}
private:
// The following method uses Add to add dates that are
// bolded, followed by an UpdateBoldedDates to make the
// added dates visible.
void loadDates()
{
String^ myInput;
try
{
StreamReader^ myInputStream = File::OpenText( "myDates.txt" );
while ( (myInput = myInputStream->ReadLine()) != nullptr )
{
monthCalendar1->AddBoldedDate( DateTime::Parse( myInput->Substring( 0, myInput->IndexOf( " " ) ) ) );
listBox1->Items->Add( myInput );
}
monthCalendar1->UpdateBoldedDates();
myInputStream->Close();
File::Delete( "myDates.txt" );
}
catch ( FileNotFoundException^ fnfe )
{
// Code to handle a file that could not be found should go here.
Console::WriteLine( "An error occurred: '{0}'", fnfe );
}
}
// The following method uses Add to add dates that are
// bolded, followed by an UpdateBoldedDates to make the
// added dates visible.
private void LoadDates()
{
String myInput;
try {
StreamReader myInputStream = File.OpenText("myDates.txt");
while ((myInput = myInputStream.ReadLine()) != null) {
monthCalendar1.AddBoldedDate(DateTime.Parse(
myInput.Substring(0, myInput.IndexOf(" "))));
listBox1.get_Items().Add(myInput);
}
monthCalendar1.UpdateBoldedDates();
myInputStream.Close();
File.Delete("myDates.txt");
}
catch (FileNotFoundException fnfe) {
// Code to handle a file that could not be found should go here.
Console.WriteLine("An error occurred: '{0}'", fnfe);
}
} //LoadDates
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
参照
関連項目
MonthCalendar クラス
MonthCalendar メンバ
System.Windows.Forms 名前空間
UpdateBoldedDates
BoldedDates