【问题标题】:Bold database dates in MonthCalendarMonthCalendar 中的粗体数据库日期
【发布时间】:2015-12-03 12:23:07
【问题描述】:

当有一个事件保存到该特定日期时,我正在尝试使我的日历编号变为粗体。我已经搜索并尝试过,但我做不到。

当我将事件保存到所选日期时,如何使日期变为粗体?

这是我尝试做的,但它无法转换为日期的一维数组。

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

【问题讨论】:

    标签: mysql vb.net monthcalendar


    【解决方案1】:

    在日历中添加粗体日期 - 示例:

        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
    

    【讨论】:

    • 兄弟。我收到 Missingmemberexemption 请帮忙
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多