|
-
July 25th, 2007, 01:21 PM
#1
[RESOLVED] Need a way to store and retrieve 31 Strings in a Property
Since I haven't had much luck solving this problem myself, I'd thought I'd throw out what I'm trying to solve and see if someone has another way of doing what I want.
I have a CustomCalendar control. It contains 31 RichTextBoxes (one for each day of the month) where data can be entered during run time. I would like to have a Property where this information can be loaded and retrieved by the programmer.
As I mentioned above, I have tried a Collection of RichTextBox and a Collection of Strings and neither worked. Has anyone done anything similar?
-
July 25th, 2007, 01:27 PM
#2
Re: Need a way to store and retrieve 31 Strings in a Property
A collection of strings, either List(of string) or the likes, should work just fine. You can further restrict it by making your collection string[31] if you want.
on data bind, load the strings from the string collection into the rich text box's.
Don't make the mistake of assuming that it should auto data bind because you've set a string. Stick to the model laid out by other .NET controls and you'll be fine: set the DataSource (in this case, just setting up the string collection property) and then call DataBind() and have your already-created controls load in their data from your data source.
cheers!
-eli
Edit: I didn't look at what board we were in before posting and posted some C#
-
July 27th, 2007, 03:00 PM
#3
Resolved: Need a way to store and retrieve 31 Strings in a Property
I ended up throwing out the Collection idea and settling for a simple DateText Property. Works great!
Code:
<Category("Appearance"), DefaultValue(""), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
Description("Calendar Day Text.")> _
Public Property DayText(ByVal iIndex As Integer) As RichTextBox
Get
Dim iPanelControlIndex, iControlIndex As Integer
' RichTextBoxes are contained within a SplitContainer control which is contained within a TableLayoutPanel control
DayText = Nothing
For iPanelControlIndex = 0 To Me.TableLayoutPanel1.Controls.Count - 1
iControlIndex = 0
While iControlIndex < Me.TableLayoutPanel1.Controls(iPanelControlIndex).Controls.Count
If Me.TableLayoutPanel1.Controls(iPanelControlIndex).Controls(iControlIndex).Controls(0).Tag = iIndex Then
DayText = Me.TableLayoutPanel1.Controls(iPanelControlIndex).Controls(iControlIndex).Controls(0)
Exit For
Else
iControlIndex = iControlIndex + 1
End If
End While
Next iPanelControlIndex
End Get
Set(ByVal value As RichTextBox)
Dim iPanelControlIndex, iControlIndex As Integer
' RichTextBoxes are contained within a SplitContainer control which is contained within a TableLayoutPanel control
m_MonthItem = Nothing
For iPanelControlIndex = 0 To Me.TableLayoutPanel1.Controls.Count - 1
iControlIndex = 0
While iControlIndex < Me.TableLayoutPanel1.Controls(iPanelControlIndex).Controls.Count
If Me.TableLayoutPanel1.Controls(iPanelControlIndex).Controls(iControlIndex).Controls(0).Tag = iIndex Then
m_MonthItem = Me.TableLayoutPanel1.Controls(iPanelControlIndex).Controls(iControlIndex).Controls(0)
Exit For
Else
iControlIndex = iControlIndex + 1
End If
End While
Next iPanelControlIndex
m_MonthItem = value
End Set
End Property
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
|