Results 1 to 3 of 3

Thread: Calendar Program

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2017

    Calendar Program

    I am attempting to write a calendar program, so far everything works but I want to change something and I am not sure how to do it.

    This is what I am currently achieving, the next picture is what I am wanting to do. I want to have the box with the date & rounder corners, inside each cell of the table I have.
    Name:  2017-12-16_16-46-30.jpg
Views: 127
Size:  21.9 KB

    Name:  2017-12-16_16-51-30.jpg
Views: 115
Size:  5.7 KB

    Here is my current code for the main page.

    Public Class frmMain
        Dim lblDayz As Label
        Dim y As Int32
        Dim x As Int32
        Dim ndayz As Int32
        Dim Dayofweek, CurrentCulture As String
        Private Sub Credito*******tripMenuItem_Click(sender As Object, e As EventArgs) Handles Credito*******tripMenuItem.Click
            Dim MyForm As New frmCrdtManager
        End Sub
        Private Sub IncomeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles IncomeToolStripMenuItem.Click
            Dim MyForm As New frmManagerIncome
        End Sub
        Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
        End Sub
        Private Sub BankingToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BankingToolStripMenuItem.Click
            Dim MyForm As New frmManagerInstitutions
        End Sub
        Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        End Sub
        Private Sub TableLayoutPanel1_Paint(sender As Object, e As PaintEventArgs) Handles TableLayoutPanel1.Paint
        End Sub
        Private Function LoadCalander(Optional ByVal entry As String = "") As String
            'display the current month
            comboBoxMonth.Text = DateTime.Now.Month.ToString()
            'Get there windows culture
            CurrentCulture = Globalization.CultureInfo.CurrentCulture.Name
            'display the full name of the current month
            labelMonth.Text = Application.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(comboBoxMonth.Text))
            'get the number of days in the selected month and year
            Dim Dayz As Int32 = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)
            'display the current year in the textbox
            textBoxYear.Text = DateTime.Now.Year.ToString()
            'call the checkday function
            For i As Int32 = 1 To Dayz
                ndayz += 1
                lblDayz = New Label()
                lblDayz.Name = "B" & i
                lblDayz.TextAlign = ContentAlignment.MiddleRight
                lblDayz.Text = i.ToString()
                lblDayz.BorderStyle = BorderStyle.Fixed3D
                If i = DateTime.Now.Day Then
                    lblDayz.BackColor = Color.Green
                ElseIf ndayz = 1 Then
                    lblDayz.BackColor = Color.Red
                    lblDayz.BackColor = Color.Aquamarine
                End If
                lblDayz.Font = label35.Font
                lblDayz.TextAlign = ContentAlignment.MiddleCenter
                TableLayoutPanel2.Controls.Add(lblDayz, x, y)
                lblDayz.SetBounds(x, y, 37, 27)
                x += 1
                If ndayz = 7 Then
                    x = 0
                    ndayz = 0
                    y += 1
                End If
            'return all values to default
            x = 0
            ndayz = 0
            y = 0
            Return 0
        End Function
        Function Panel()
            Return 0
        End Function
        Function CheckDay() As Int32
            Dim time As DateTime = Convert.ToDateTime(comboBoxMonth.Text + "/01/" + textBoxYear.Text)
            'get the start day of the week for the entered date and month
            Dayofweek = Application.CurrentCulture.Calendar.GetDayOfWeek(time).ToString()
            If Dayofweek = "Sunday" Then
                x = 0
            ElseIf Dayofweek = "Monday" Then
                x = 1
                ndayz = 1
            ElseIf Dayofweek = "Tuesday" Then
                x = 2
                ndayz = 2
            ElseIf Dayofweek = "Wednesday" Then
                x = 3
                ndayz = 3
            ElseIf Dayofweek = "Thursday" Then
                x = 4
                ndayz = 4
            ElseIf Dayofweek = "Friday" Then
                x = 5
                ndayz = 5
            ElseIf Dayofweek = "Saturday" Then
                x = 6
                ndayz = 6
            End If
            Return x
        End Function
    End Class

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Chelmsford UK

    Re: Calendar Program

    You need to create a UserControl, and add instances of your UC to your TableLayoutPanel, instead of adding Labels

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Chelmsford UK

    Re: Calendar Program

    To get the rounder corners, you need to create a new Region from a rounded Rectangle, and use that as your UC's Region.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width