-
Dec 16th, 2017, 04:53 PM
#1
Thread Starter
Junior Member
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.
Here is my current code for the main page.
Code:
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
MyForm.Hide()
MyForm.ShowDialog()
End Sub
Private Sub IncomeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles IncomeToolStripMenuItem.Click
Dim MyForm As New frmManagerIncome
MyForm.Hide()
MyForm.ShowDialog()
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub BankingToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BankingToolStripMenuItem.Click
Dim MyForm As New frmManagerInstitutions
MyForm.ShowDialog()
End Sub
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadCalander()
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
My.Application.ChangeCulture("en-za")
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
CheckDay()
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
Else
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
Next
'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
-
Dec 18th, 2017, 09:30 PM
#2
Re: Calendar Program
You need to create a UserControl, and add instances of your UC to your TableLayoutPanel, instead of adding Labels
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 18th, 2017, 09:32 PM
#3
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.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|