Dynamic form control properties

Discussion in 'Microsoft Dot NET' started by codeslinger73@gmail.com, Oct 29, 2006.

  1. Guest

    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
     
    , Oct 29, 2006
    #1
    1. Advertisements

  2. 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




    "" <> wrote in message
    news::

    > 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
     
    Bryan Phillips, Oct 29, 2006
    #2
    1. Advertisements

  3. Guest

    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
     
    , Nov 10, 2006
    #3
  4. Guest

    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.

    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
     
    , Nov 26, 2006
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leon Jollans

    dynamic properties

    Leon Jollans, Sep 9, 2003, in forum: Microsoft Dot NET
    Replies:
    2
    Views:
    116
    Leon Jollans
    Sep 9, 2003
  2. Nathan Baulch
    Replies:
    0
    Views:
    142
    Nathan Baulch
    Feb 23, 2004
  3. listerofsmeg

    Adding dynamic properties to a console app

    listerofsmeg, Sep 29, 2004, in forum: Microsoft Dot NET
    Replies:
    2
    Views:
    180
    listerofsmeg
    Oct 1, 2004
  4. Guest

    Dynamic Properties

    Guest, Dec 28, 2004, in forum: Microsoft Dot NET
    Replies:
    5
    Views:
    127
    Bishoy Ghaly
    Dec 31, 2004
  5. Rob

    DataGridView & Dynamic Properties

    Rob, Mar 29, 2005, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    324
    Cor Ligthert
    Mar 29, 2005
Loading...

Share This Page