回答
這是不可能的。沒有內置的方式來定製單個日期或日期顯示在MonthCalendar
控件上的方式。
你可能所有者繪製控件,但這是太多的工作來證明。這會讓你負責自己繪製整個控制。請注意,如果您選擇走此路線,MonthCalendar
控件不會引發Paint
事件,因爲基本控件將UserPaint
位設置爲「False」。您將不得不繼承控件的子類並覆蓋其OnPrint
method。
我不能親自推薦提供這種級別的自定義任何第三方控件,但快速谷歌搜索確實出現調高几個選項:
在Visual Studio 2005中,u從工具箱拖動MONTHCALENDAR。
轉到屬性。
每年都會顯示粗體日期,每月加粗日期和粗體日期。你可以在這些屬性中添加你想要的日期。
VS 2010,Winform – 2011-02-19 05:02:58
這隻會使日期加粗,我想改變一些特定日期的顏色 – 2011-02-19 05:04:09
第1步:拖動網格視圖控制和日曆在Web窗體或窗體上:
步驟2:粘貼的.cs頁面上的編碼
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
public partial class frmCalander : System.Web.UI.Page
{
SqlConnection con= new SqlConnection();
SqlDataAdapter myda;
DataSet ds = new DataSet();
DataSet dsSelDate;
String strConn;
protected void Page_Load(object sender, EventArgs e)
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["STUDENTConnectionString"].ConnectionString;
myda = new SqlDataAdapter("Select * from EventTable", con);
myda.Fill(ds, "Table");
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (! e.Day.IsOtherMonth)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
if ((dr["EventDate"].ToString() != DBNull.Value.ToString()))
{
DateTime dtEvent= (DateTime)dr["EventDate"];
if (dtEvent.Equals(e.Day.Date))
{
e.Cell.BackColor = Color.PaleVioletRed;
}
}
}
}
//If the month is not CurrentMonth then hide the Dates
else
{
e.Cell.Text = "";
}
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
myda = new SqlDataAdapter("Select EventId, EventName, EventLocation, Convert(varchar,EventDate,105) as EventDate from EventTable where EventDate='" + Calendar1.SelectedDate.ToString() + "'", con);
dsSelDate = new DataSet();
myda.Fill(dsSelDate, "AllTables");
if (dsSelDate.Tables[0].Rows.Count == 0)
{
GridView1.Visible = false;
}
else
{
GridView1.Visible = true;
GridView1.DataSource = dsSelDate;
GridView1.DataBind();
}
}
嘗試這種情況:
Private Sub pintaCalendarioNaData(ByRef mc As MonthCalendar, ByVal data As Date, ByVal cor As String)
Dim gMonthCalendar As Graphics = mc.CreateGraphics()
Dim oHTIMonths As MonthCalendar.HitTestInfo
Dim arrDates As New ArrayList()
Try
For intRows As Integer = 1 To mc.Size.Width - 1
For intCols As Integer = 1 To mc.Size.Height - 1
oHTIMonths = mc.HitTest(intRows, intCols)
If oHTIMonths.HitArea = MonthCalendar.HitArea.Date Then
If CDate(mc.HitTest(intRows, intCols).Time) = CDate(data) Then
gMonthCalendar.DrawRectangle(New Pen(ColorTranslator.FromHtml(cor), 2), intRows, intCols, 24, 15)
GoTo fim
End If
End If
Next intCols
Next intRows
fim:
Catch ex As Exception
MessageBox.Show("Error: " & vbNewLine & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Err.Clear()
Finally
End Try
End Sub
此子塗料一個的MonthCalendar(MC)在一個特定的日期(數據)用一種顏色( cor)
- 1. Fullcalendar更改某些事件的顏色
- 2. 更改日期顏色
- 3. 更改某些圖表點的顏色
- 4. 更改某些字符的顏色
- 5. 更改日曆日期的顏色android
- 6. 如何在xtable markdown中更改某些單元格的顏色?
- 7. 如何更改TextView中的某些字符顏色
- 8. ASP.NET:如何更改gridview中某些文本的顏色?
- 9. 在MonthCalendar控制中的迭代日期
- 10. 更改給定日期的顏色?
- 11. 控件更改顏色
- 12. ReportViewer更改控件顏色
- 13. 的MonthCalendar C#的WinForms亮點日期顏色
- 14. 如何更改MS Silverlight日曆控件中藍色邊框的顏色?
- 15. Android:如何更改DatePicker元素中選定日期的顏色?
- 16. 如何更改Datechooser中的選定日期文字顏色?
- 17. 如何更改android中特定日期的背景顏色?
- 18. 如何更改Jquery UI日曆小部件中各個日期的顏色?
- 19. 如何更改tkinter文本小部件中某些單詞的顏色?
- 20. 如何根據EXTJS中的某些條件更改行背景顏色
- 21. 如何更改默認日期選擇器中的日期顏色
- 22. 日曆控件的粗體文本中的顏色更改
- 23. JCalendar:如何更改某些日子的前景色?
- 24. 如何根據今天的日期更改行的BG顏色
- 25. 如何在monthCalendar中標記日期?
- 26. datagridview的更改行的顏色,當日期過期或更少
- 27. 如何更改mfc中列表控件中的高亮顏色
- 28. 使用jquery更改Textarea中某些單詞的顏色?
- 29. 更改proc sgplot vbar中某些條的顏色
- 30. 更改某些字符的顏色並在RichTextBox中計數
這是你的視覺工作室版本嗎? 2005年或2008年或2010年。我可以假設monthcalendar是winform嗎? – william 2011-02-19 04:39:31
VS 2010,Winform – 2011-02-19 05:02:40