473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamic form control properties

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 '06 #1
3 1254
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


"co***********@gmail.com" <co***********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com:
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 '06 #2
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 '06 #3
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.

co***********@gmail.com 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 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nathan Baulch | last post by:
I have an XML file that my application reads at runtime: <form> <control clsid="B5ECA9DC-879F-40BC-9298-3E399E099C0B"> <name>btnGO</name> <top>10</top> <left>10</left> <myint>273</myint>...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
2
by: MikeY | last post by:
Hiya All, I'm coding in C#, & making a windows application. I am trying to figure out how to put my dynamic control code in a seperate class (say ie ButtonClass.cs) so that I can re-use the code...
6
by: MikeY | last post by:
Hi Everyone, Does anyone know where I can get my hands on a sample with source code of a simple dynamic button control in C# Windows form. I am looking for a sample that uses a class library...
1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
0
by: Steve Funk | last post by:
All, I have searched all around and have not yet found the answer to this nor a solution. Hopfully it will be easy to overcome. Here is what I am trying to do: I'm trying to build a wizard...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.