WPF Array of UserControls
I am working on a project and there are about 30 controls that I need to call and update at runtime. I have named the controls day0 - day35 (it is a calendar). Basically, at runtime, I need to call each control's setDate function to display the day number. When I run it, the array just has null/empty.
This is the array I am trying to use in the code behind. The controls are names day0-day35.
Private dateArr() As ucMonthDay = {day0, day1, day2, day3, day4, day5, _
day6, day7, day8, day9, _
day10, day11, day12, day13, day14, day15, day16, day17, day18, day19, _
day20, day21, day22, day23, day24, day25, day26, day27, day28, day29, _
day30, day31, day32, day33, day34}
Then I want to be able to loop through this array and set the date on each of the controls:
Dim counter As Integer = 0
While (counter < 35)
dateArr(counter).setDate(firstDay)
firstDay.AddDays(1)
counter += 1
End While
When this gets called, I get a null pointer exception. I do not understand why the controls are not in the 开发者_C百科array?
Thanks for your help.
Kevin
You should first create your objects
精彩评论