preserve custom property value

I am extending PictureBox control and added the following code

    Private clrForeColor As Color = Color.Black

    <Browsable(True)> _
    Overrides Property ForeColor() As Color
        Get
            Return clrForeColor
        End Get
        Set(ByVal Value As Color)
            clrForeColor = Value
            MyBrush.Color = clrForeColor
            Me.Invalidate()
        End Set
    End Property

Whe I change my ForeColor property from the property window the color changes but when executing the application the color rturns to black. How o solve this problem?
f_asmaaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arif_eqbalCommented:
That's because your code executes only at run time

I think you need to create a custom control for that, extend the picture box using a new Windows Control Library Project and adding your code then use this new control.

0
f_asmaaAuthor Commented:
What do you mean by executing the code at run time??????
0
arif_eqbalCommented:
How have you extended the Picture Box Control
It must be a class within your project

However when you access the property pages it is the basic PictureBox control isn't it
And not your extended class



0
f_asmaaAuthor Commented:
No I see the additional property that I added. I added a control library project to my application and added referenc to from my application.
0
RonaldBiemansCommented:
Hi, call the base class forecolor

<Browsable(True)> Public Overrides Property ForeColor() As Color
        Get
            Return clrForeColor
        End Get
        Set(ByVal Value As Color)
            clrForeColor = Value
            MyBrush.Color = clrForeColor
            Me.Invalidate()
'*****
            MyBase.ForeColor = Value
'*****
        End Set
    End Property
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.