Hi Fergus,
thanks for your reply.
This is quite a challenging project. ;-)
First some questions:
1. Is this for work or for your own use/fun?
This is my work project and yes, it is probably going to be big but I have
to build it anyways.
2. Do you have a deadline?
For sure but I don't know it yet, probably about a month of time left
Little bit, but the project is not web based, I am building it on windows
form
4. If not, is it on your list of things to learn?
I'd certainly like to learn it. Beside all that functionality, it has to
look good too, so I will probably have to customize some of the controls, I
did my first 'owner drawn' menu and it looks cool. Would really like to be
able to simillar with other controls.
Now - the project.
The first thing to realise is that each Day is going to have several
elements. There will be the Header which will display the day number, and the
Body which will display a version of the Message for that Day. That Message
could be composed of one or more events or just be a single piece of text. It
may or may not fit inside the Body. You'll want to provide some way to
enter/edit that Message which will require a TextBox of some flavour. You'll
want a ContextMenu for your popup options. You might consider having a ToolTip
(.NET's or your own version of the same) which can display the Day's Message
when it is too big to fit inside the Body. A Day may belong to the current
month or it might be for the previous or next months. This Day will have to
work as well as the others but look different. Some Days may need to appear
different depending on, for example, the type of Message that they contain, eg
a birthday notification.
All of that just for one day. And a month's worth of all that for the
whole Form. To me, that screams UserControl in a very loud voice. It also says
that there are several classes which will be needed to manage all of this, eg
Message (or whatever you choose to call it). So I recommend that you start
your design off by considering how you'd like just a single Day to look and
behave.
You are right, all that functionality is needed. I have designed everything
already and am building the gui. So far, I get 7X5 grid of panels
displayed. Now I have to add a label (header) and a text box (body) to each
of the cells and make somehow everthing resize appropriatelly as user
resizes the form.
Have one problem though. I am adding the labels and text boxes to each
panel in a loop. However, only first panel gets added a lable and a text
box to it, the others don't. I don't know why. Here is the code
Private Sub frmMonthlyCalendar_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim aPanelCollection As New Collection()
Dim pn As Panel
Dim lbl As Label
Dim txt As TextBox
Dim intI As Integer = 0
' upper right coordinates of panel, lable and text box
Dim pnX As Integer = 0, pnY As Integer = 20
Dim lbX As Integer = 0, lbY As Integer = 0
Dim txX As Integer = 0, txY As Integer = 15
' draw 35 panels each with a label and text box inside
While intI <= 35
pn = New Panel()
lbl = New Label()
txt = New TextBox()
If ((intI <> 0) And (intI Mod 7 <> 0)) Then
pn.Location = New Point(pnX, pnY)
pn.Size = New Size(85, 70)
pn.BorderStyle = BorderStyle.FixedSingle
lbl.Text = intI.ToString ' display number in the label
lbl.Location = New Point(pnX, lbY)
lbl.Size = New Size(85, 15)
lbl.BackColor = System.Drawing.Color.Gainsboro
txt.AutoSize = False
txt.Location = New Point(pnX, lbY + 15)
txt.Size = New Size(85, 55)
txt.BorderStyle = BorderStyle.None
txt.BackColor = System.Drawing.Color.White
' add label and text box to panel
pn.Controls.Add(lbl)
pn.Controls.Add(txt)
' add panel (calendar cell) to big panel. This panel holds
all small panels representing days
aCalendarPanel.Controls.Add(pn)
pnX = pnX + aCalendarPanel.Controls.Item(1).Size.Width
Else
' when moving to next row, reset coordinates
If intI = 0 Then
pnX = 0
pnY = 20
lbX = 0
lbY = 0
txX = 0
txY = 15
Else
pnX = 0
pnY = pnY + aCalendarPanel.Controls.Item(1).Size.Height
lbX = 0
lbY = lbY + aCalendarPanel.Controls.Item(1).Size.Height
txX = 0
txY = txY + aCalendarPanel.Controls.Item(1).Size.Height
End If
pn.Location = New Point(pnX, pnY)
pn.Size = New Size(85, 70)
pn.BorderStyle = BorderStyle.FixedSingle
lbl.Location = New Point(pnX, lbY)
lbl.Size = New Size(85, 15)
lbl.BackColor = System.Drawing.Color.Gainsboro
txt.AutoSize = False
txt.Location = New Point(pnX, lbY + 15)
txt.Size = New Size(85, 55)
txt.BorderStyle = BorderStyle.None
txt.BackColor = System.Drawing.Color.White
' add label and text box to the panel
pn.Controls.Add(lbl)
pn.Controls.Add(txt)
' add panel (calendar cell) to big panel. This panel holds
all small panels representing days
aCalendarPanel.Controls.Add(pn)
pnX = pnX + aCalendarPanel.Controls.Item(1).Size.Width
End If
' ad day panel to the collection
aPanelCollection.Add(pn)
intI += 1
End While
End Sub