Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Reference Exception #6

Open
lordofscripts opened this issue Dec 27, 2017 · 1 comment
Open

Null Reference Exception #6

lordofscripts opened this issue Dec 27, 2017 · 1 comment

Comments

@lordofscripts
Copy link

In your demo if you use the default value of the last parameter of CarClock constructor (or set it to false) then the demo will throw a NullReferenceException on setting the Location property of CarClock.ClockPanel

@Jonathan435
Copy link
Owner

Jonathan435 commented Jan 5, 2018

The reason for that exception is that if BaseBar is required (last parameter set to true)
the Clock will be contained inside a panel (ClockPanel) hence, you must use ClockPanel insted of Clock
if last parameter set to false, ClockPanel will never be initialized and you must use Clock. in the example I use the ClockPanel Location in order to set the GoalsClock location, so if AddBaseBar is set to false, use Clock location. for example:

' AddBaseBar = false
        CarClock = New BusinessClocks.ExecutiveClocks.CarClock(300, 150, 0.8, False)
        CarClock.ShowInnerCutForPerformance = False
        CarClock.BarBackColor = Color.Pink
        CarClock.Create(True)
        Me.Controls.Add(CarClock.Clock) ' use Clock and not ClockPanel here

        GoalsClock = New GoalsClock(200, 200, 0.8)
        GoalsClock.Create(True)
        GoalsClock.Clock.Location = New Point(0, CarClock.Clock.Location.Y + CarClock.Clock.Height + 5) ' you dont need to add the bar height: + CarClock.ClockPanel.Height + 5, replace with clock height in order to get the Y point of the bottom of the clock
        Me.Controls.Add(GoalsClock.Clock)

I know it is confusing do you have a better solution rather than raising an exception?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants