calender1_dayRender()
dayRender
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { Literal l = new Literal(); //Creating a literal l.Visible = true; l.Text = "<br>"; //for breaking the line in cell e.Cell.Controls.Add(l); //adding in all cell da = new SqlDataAdapter("select * from Events", con); DataTable dt = new DataTable(); da.Fill(dt); foreach(DataRow dr in dt.Rows) { string x = dr[1].ToString(); if (dr[1].ToString() == e.Day.Date.ToString()) //comparision { Label lb = new Label(); lb.Visible = true; lb.Text = dr[0].ToString(); string a = lb.Text; e.Cell.Controls.Add(lb); e.Cell.BackColor = System.Drawing.Color.OrangeRed; // changing cell color e.Cell.ToolTip = dr[0].ToString(); //adding tooltip } }
Quote:how we can show calendar data from the database to calender in c# winform.
Quote:To select a range of dates 1.Create DateTime objects that represent the first and last dates in a range. C# DateTime projectStart = new DateTime(2001, 2, 13); DateTime projectEnd = new DateTime(2001, 2, 28); 2. Set the SelectionRange property. C# monthCalendar1.SelectionRange = new SelectionRange(projectStart, projectEnd); or 3. Set the SelectionStart and SelectionEnd properties. C# monthCalendar1.SelectionStart = projectStart; monthCalendar1.SelectionEnd = projectEnd;
DateTime projectStart = new DateTime(2001, 2, 13); DateTime projectEnd = new DateTime(2001, 2, 28);
SelectionRange
monthCalendar1.SelectionRange = new SelectionRange(projectStart, projectEnd);
SelectionStart
SelectionEnd
monthCalendar1.SelectionStart = projectStart; monthCalendar1.SelectionEnd = projectEnd;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)