OK,
I've created a custom Calendar control that works very well. I'm now trying to provide the user a way to load and save the Calendar data. I've chosen to save the data in a Collection (Of RichTextBox).
Here's the Property definition:
Here's the initialization of the Collection in New():Code:Private m_MonthItemCollection As New Collection(Of RichTextBox) <Category("Appearance"), _ DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _ Description("Calendar Item Data Collection.")> _ Public Property MonthItemCollection() As Collection(Of RichTextBox) Get MonthItemCollection = m_MonthItemCollection End Get Set(ByVal value As Collection(Of RichTextBox)) Dim iIndex As Integer m_MonthItemCollection = value For iIndex = 1 To m_MonthItemCollection.Count AssignValuesToCalendar(iIndex) Next iIndex End Set End Property
Code:Dim iIndex As Integer Dim MyRTB As RichTextBox For iIndex = 0 To 30 MyRTB = New RichTextBox m_MonthItemCollection.Add(MyRTB) Next iIndex
and here's the code that assigns the correct RichTextBox to the Collection:
and here's the code that the user calls to get the data from the control:Code:Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged Dim iCollectionIndex As Integer iCollectionIndex = CInt(Val(lblDay1.Text)) - 1 m_MonthItemCollection(iCollectionIndex) = RichTextBox1 End Sub
If I stop in the Control (i.e. in RichTextBox1_TextChanged), the data looks fine, but when I stop in Button1_Click, there is no text in the collection. Any ideas?Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click RichTextBox1 = CalendarControl1.MonthItemCollection(CInt(NumericUpDown1.Text) - 1) End Sub




Reply With Quote