当我将某个事件保存到该特定日期时,我正在尝试将我的日历编号设为粗体。我已经搜索并试图这样做,但我不能。
如果我将事件保存到所选日期,如何将日期设为粗体?
这是我试图做的但却无法转换为1维日期数组。
mydbcon = New MySqlConnection
mydbcon.ConnectionString = "server=localhost;userid=root;password=root;database=database"
Dim reader As MySqlDataReader
Dim bold = Form4.MonthCalendar1.SelectionRange.Start.Month
Try
mydbcon.Open()
Dim Query As String
Query = "Insert into database.calendar (eventname,Date,Time,Description) Values ('" & TextBox2.Text & "','" & Form4.MonthCalendar1.SelectionRange.Start & "','" & ComboBox1.SelectedItem & "','" & TextBox1.Text & "')"
COMMAND = New MySqlCommand(Query, mydbcon)
reader = COMMAND.ExecuteReader
MessageBox.Show("Event Succesfully Saved")
Form4.MonthCalendar1.BoldedDates = bold
mydbcon.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
mydbcon.Dispose()
End Try
答案 0 :(得分:0)
在日历中添加粗体日期 - 例如:
MonthCalendar1.AddBoldedDate(CDate("03-12-2015"))
MonthCalendar1.UpdateBoldedDates()
从数据库中读取日期 - 例如:
mydbcon = New MySqlConnection
mydbcon.ConnectionString = "server=localhost;userid=root;password=root;database=database"
Dim reader As MySqlDataReader
Try
mydbcon.Open()
Dim Query As New MySql.Data.MySqlClient.MySqlCommand
Dim eventDate As String
Query.Connection = mydbcon
Query.CommandText = "SELECT Date FROM database ORDER BY Date"
reader = Query.ExecuteReader
If reader.HasRows = True Then
While reader.Read
eventDate = reader.GetValue(reader.GetOrdinal("Date")).ToShortDateString
MonthCalendar1.AddBoldedDate(CDate(eventDate))
End While
reader.Close()
MonthCalendar1.UpdateBoldedDates()
End If
mydbcon.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
mydbcon.Dispose()
End Try