Label inside Rectangle
-
I am trying to add a month view calendar that will display the time and description of the event within each day (using VB.NET 2005). My current attemt is to draw a series of rectangles and place text within each. I am able to create my calendar, put the day inside each box...so the calendar is there. My problem is placing a label, text, etc. within each box to display the event. I would also need to be able to double-click the item and open a form containg the detail for the item. If someone could point me in the right direction (even if it means starting over and taking a new path) I would greatly appreciate it. Many thanks in advance. -- modified at 21:55 Monday 16th October, 2006
-
I am trying to add a month view calendar that will display the time and description of the event within each day (using VB.NET 2005). My current attemt is to draw a series of rectangles and place text within each. I am able to create my calendar, put the day inside each box...so the calendar is there. My problem is placing a label, text, etc. within each box to display the event. I would also need to be able to double-click the item and open a form containg the detail for the item. If someone could point me in the right direction (even if it means starting over and taking a new path) I would greatly appreciate it. Many thanks in advance. -- modified at 21:55 Monday 16th October, 2006
You can create them dynamically in code. Declare the label outside of any subs using the "WithEvents" keyword - this will allow you to attach a double-click event to the label through making use of the AddHandler method. You will have to add your own code to determine how many labels you'll need, I've just used a loop to demonstrate.
Private WithEvents lblEvent As Label
Private Sub MySub()'dynamically add labels
Dim i As Integer
Do Until i = 30
lblEvent = New Label
lblEvent.Text = "Event Label " & i.ToString
AddHandler lblEvent.DoubleClick, AddressOf lblEvent_DoubleClick
'add the label to a control
Me.Controls.Add(lblEvent)
Loop
End SubPrivate Sub lblEvent_DoubleClick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles lblEvent.DoubleClick
'add processing here
End Sub