Dynamic form control properties

C

codeslinger73

I ran into sort of a timing issue. I want to hold some default
properties for form controls (font, borderstyle, etc) in the registry
or a config file and then update these things after init but before the
paint. The problem is that the form's InitializeComponent() calls the
control's constructor and then updates the control's properties with
whatever it found during design time. So, i can change the properties
in the constructor of the control, but that gets buried right after.

I've tried overriding things like OnPaint and even using a message pump
to get to this right before the control is painted. One issue is that
in C# I wasn't able to get the timing right, another issue is that I
don't want this done more than once. The real goal is for this to be a
part of the control, which is in a library, and can be transparent to
any form that this gets dropped on.

Anyone else ever needed to do something like this?

Mark
 
C

codeslinger73

Thaks for the suggestion. I had tried something like what you're
talking about, but I don't know how to get the parent form. I'm not
even sure it's available at this point. When a control like this is
created and the constructor is called it's just kinda floating, isn't
it? It doesn't have a parent form till the Controls.Add(control) is
called?

Anyway, I get null from .FindForm() and .Parent which leads me to
belive, it's not there.

Is there a better event of the control to do this in?


Mark
 
C

codeslinger73

Hate to bump posts but I still havn't been able to make this work or to
work around it. As little as I like the idea, I'm now willing to tie
this control library to one specific class of Form and just inherit
from it every time.

Suggestions for a route here? None of the control's events seem like
the correct place to do this setup one time only. I have a couple of
ideas but they seem like serious hacks and if there's a right way to do
this thing i'd like to try it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top