PC Review


Reply
Thread Tools Rate Thread

Dynamic form control properties

 
 
codeslinger73@gmail.com
Guest
Posts: n/a
 
      29th Oct 2006
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

 
Reply With Quote
 
 
 
 
Bryan Phillips
Guest
Posts: n/a
 
      29th Oct 2006
In the control's constructor, why don't you add an event handler to the
form's load event and apply the new properties values?

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com




"(E-Mail Removed)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed):

> 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


 
Reply With Quote
 
 
 
 
codeslinger73@gmail.com
Guest
Posts: n/a
 
      10th Nov 2006
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

 
Reply With Quote
 
codeslinger73@gmail.com
Guest
Posts: n/a
 
      26th Nov 2006
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.

(E-Mail Removed) wrote:
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Form control properties don't reflect changes to source table field properties Ken Snell MVP Microsoft Access VBA Modules 0 13th Sep 2009 01:50 PM
Re: Form control properties don't reflect changes to source table field properties Ken Snell [MVP] Microsoft Access VBA Modules 0 13th Sep 2009 01:47 PM
placement of dynamic control depends on VALUE of dynamic control Larry Bud Microsoft ASP .NET 1 10th Jan 2007 11:07 PM
Dynamic Events from Dynamic Controls on a User Control - Guess What? Broken! mytestemailaccount@gmail.com Microsoft ASP .NET 5 23rd Mar 2005 06:06 PM
Dynamic control on aspx page, dynamic location Chris Thunell Microsoft ASP .NET 3 21st Jul 2004 05:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:23 AM.