473,734 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Manually creating a form

Hi there,

I'd like to re-create a form given only its resource file. I was going to
simply read the resource file and re-create the "Form" object and all its
controls as found in this file (applying all properties in the file and
relying on the default properties for those not found). After looking at
"InitializeComp onent()" however (which is what I'm really trying to
re-produce here), can somone explain why this function does the following:

1) Manually sets the "Name" property for each control which overwrites the
same property found in the resource file itself (athough the names are the
same - it should rely solely on the resource file however). E.g., I see this
in code *after* reading the same value from the resource file:

this.MyButton.N ame = "MyButtonNa me";

2) Occasionally adds other properties in code such as:

this.MyButton.U seVisualStyleba ckColor = true
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
etc.

How is anyone supposed to to know to apply the above properties and possibly
others when all you have is the resource file to work with? Moreover, is
there a more appropriate (official) way to generate a form from its resource
file (manually doing it is tedious and error prone). Thanks.
Jun 20 '06 #1
10 2229
Those code is generated when you drag a control on a form or set its
properties. Today VB.NET has a free tool called VB.NET 2005 Express so why
worry to reproduce the form from the resource file?

chanmm
"Jake Forson" <no_spam@_nospa m.com> wrote in message
news:Ou******** ******@TK2MSFTN GP05.phx.gbl...
Hi there,

I'd like to re-create a form given only its resource file. I was going to
simply read the resource file and re-create the "Form" object and all its
controls as found in this file (applying all properties in the file and
relying on the default properties for those not found). After looking at
"InitializeComp onent()" however (which is what I'm really trying to
re-produce here), can somone explain why this function does the following:

1) Manually sets the "Name" property for each control which overwrites the
same property found in the resource file itself (athough the names are the
same - it should rely solely on the resource file however). E.g., I see
this in code *after* reading the same value from the resource file:

this.MyButton.N ame = "MyButtonNa me";

2) Occasionally adds other properties in code such as:

this.MyButton.U seVisualStyleba ckColor = true
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
etc.

How is anyone supposed to to know to apply the above properties and
possibly others when all you have is the resource file to work with?
Moreover, is there a more appropriate (official) way to generate a form
from its resource file (manually doing it is tedious and error prone).
Thanks.

Jun 20 '06 #2
> Those code is generated when you drag a control on a form or set its
properties. Today VB.NET has a free tool called VB.NET 2005 Express so why
worry to reproduce the form from the resource file?


My application requires it.
Jun 20 '06 #3
I have a somewhat similar requirement, but I never understood that resource
files to be a full representation of a form's design. I thought they were
just used for localization. Is there some documentation section I missed
and should read?

"Jake Forson" <no_spam@_nospa m.com> wrote in message
news:Ou******** ******@TK2MSFTN GP05.phx.gbl...
Hi there,

I'd like to re-create a form given only its resource file. I was going to
simply read the resource file and re-create the "Form" object and all its
controls as found in this file (applying all properties in the file and
relying on the default properties for those not found). After looking at
"InitializeComp onent()" however (which is what I'm really trying to
re-produce here), can somone explain why this function does the following:

1) Manually sets the "Name" property for each control which overwrites the
same property found in the resource file itself (athough the names are the
same - it should rely solely on the resource file however). E.g., I see
this in code *after* reading the same value from the resource file:

this.MyButton.N ame = "MyButtonNa me";

2) Occasionally adds other properties in code such as:

this.MyButton.U seVisualStyleba ckColor = true
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
etc.

How is anyone supposed to to know to apply the above properties and
possibly others when all you have is the resource file to work with?
Moreover, is there a more appropriate (official) way to generate a form
from its resource file (manually doing it is tedious and error prone).
Thanks.

Jun 20 '06 #4
>I have a somewhat similar requirement, but I never understood that resource
files to be a full representation of a form's design. I thought they were
just used for localization. Is there some documentation section I missed
and should read?


They are used just for localization. You can re-create the entire form from
the ".resx" files however once your app is localized. This won't include
anything extra however that either "InitializeComp onent()" adds or the
developer himself (immediately after the call to "InitializeComp onent()"
normally). This is fine for my own purposes (not sure about yours - you may
want to elaborate) but I don't understand why "InitializeComp onent()" needs
to add any extraneous code at all (as mentioned in my last post). It seems
to me that once a form is localized, you should be able to re-create it
based purely on what's in the resource files alone (not including any
non-localized customization by the developer as noted).
Jun 21 '06 #5

"Jake Forson" <no_spam@_nospa m.com> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
It seems to me that once a form is localized, you should be able to
re-create it based purely on what's in the resource files alone (not
including any non-localized customization by the developer as noted).


I don't follow this logic. The express purpose of the resx file is not to
provide a full description of the form's design but rather to provide
description of those aspects of a form's design that could change between
languages, etc. I don't understand how you can be critical of something for
being incomplete in a purpose for which it is not intended (for "not
including any non-localized customization") .

I'm not meaning to argue for its own sake, I truly just am puzzled by your
statements.

Can I use a semi tractor/trailer to go get McDonald's? Yes, with some
special effort and some limitations. Should I criticize a semi
tractor/trailer for not fitting in the drive-in window? No, of course not.
Jun 22 '06 #6
> I don't follow this logic. The express purpose of the resx file is not to
provide a full description of the form's design but rather to provide
description of those aspects of a form's design that could change between
languages, etc. I don't understand how you can be critical of something
for being incomplete in a purpose for which it is not intended (for "not
including any non-localized customization") .

I'm not meaning to argue for its own sake, I truly just am puzzled by your
statements.

Can I use a semi tractor/trailer to go get McDonald's? Yes, with some
special effort and some limitations. Should I criticize a semi
tractor/trailer for not fitting in the drive-in window? No, of course
not.


In raw Windows a form can be completely descibed in a self-contained ".rc"
file or its compiled ".res" equivalent. There's no such analogue in .NET
however so how do you pull a form out of a Visual Studio (VS) project so it
can be sent off to another program for processing? Let's say program A
exists on a machine without VS installed for instance and it justs wants to
display some form from an arbitrary VS project. The only practical way I can
seem to find to pull this off is to send all of the form's ".resx" or
".resources " file to program A (one such file for each supported language),
where program A can then construct a "System.Windows .Forms.Form" object and
apply all controls, properties, etc. found in these ".resx" files (with all
other properties already set to their default values at time of object
construction). Will this result in the same form that
"InitializeComp onent()" creates back where the project is actually compiled?
(excluding whatever code the programmer adds after the call to
"InitializeComp onent()"). No because "InitializeComp onent()" sets certain
other properties in code that don't originate from the ".resx" file. So how
is program A supposed to know that it should also set these properties when
all it has is the ".resx" or "resources" files to work with. Maybe there's
another (non-trivial) way to do this such as a native .NET class that
program A can call to re-construct "InitializeComp onent()" on-the-fly. It
eludes me so far however so maybe eating at McDonald's isn't always the
healthiest thing after all :)
Jun 22 '06 #7
Well, you could always dyamically load the resultant assembly and use
reflection to create an instance of the form? No VS required - just the
framework...

At the end of the day, not all forms involve resource files... does that
mean they aren't proper forms? I hope not...

(might want to think about security loading random dlls, but heh!)

Marc
Jun 22 '06 #8
> Well, you could always dyamically load the resultant assembly and use
reflection to create an instance of the form? No VS required - just the
framework...
How? I would have to send the assembly itself out (not good) and then what?
Any code that the programmer added after the call to "InitializeComp onent()"
will also get executed. I have no idea what this could be so it's
potentially big trouble (could be doing anything from looking for a
non-existent DB in order to initialize the form to potentially violationg
the local security policy on the machine).
At the end of the day, not all forms involve resource files... does that
mean they aren't proper forms? I hope not...


In my case I'm dealing with localized forms only so by definition they
should be following the hub and spoke model (resources should exist).

Thanks for the feedback however :)
Jun 22 '06 #9

"Jake Forson" <no_spam@_nospa m.com> wrote in message
news:eF******** ******@TK2MSFTN GP03.phx.gbl...

In raw Windows a form can be completely descibed in a self-contained ".rc"
file or its compiled ".res" equivalent. There's no such analogue in .NET
however so how do you pull a form out of a Visual Studio (VS) project so
it can be sent off to another program for processing? Let's say program A
exists on a machine without VS installed for instance and it justs wants
to display some form from an arbitrary VS project. The only practical way
I can seem to find to pull this off is to send all of the form's ".resx"
or ".resources " file to program A (one such file for each supported
language), where program A can then construct a
"System.Windows .Forms.Form" object and apply all controls, properties,
etc. found in these ".resx" files (with all other properties already set
to their default values at time of object construction). Will this result
in the same form that "InitializeComp onent()" creates back where the
project is actually compiled? (excluding whatever code the programmer adds
after the call to "InitializeComp onent()"). No because
"InitializeComp onent()" sets certain other properties in code that don't
originate from the ".resx" file. So how is program A supposed to know that
it should also set these properties when all it has is the ".resx" or
"resources" files to work with. Maybe there's another (non-trivial) way to
do this such as a native .NET class that program A can call to
re-construct "InitializeComp onent()" on-the-fly. It eludes me so far
however so maybe eating at McDonald's isn't always the healthiest thing
after all :)


Again, you speak of this as if it's some flaw in the design of .NET or VS or
something. I guess that's what is puzzling me.

My understanding is that you have a specific need to represent a form's
design in some neutral way for passing between programs. Sounds like custom
functionality to me. Are you trying to create your own forms
designer/editor?

Why would Program A need to "reconstruc t" InitializeCompo nent? It either
has access to the .cs file and could read it itself or you need some kind of
custom transport. Maybe all my McDonalds is making me dense, but I'm not
just seeing why you're insisting on cramming the square peg into the round
hole.

You might want to check out the WPF / XAML capabilities in the upcoming
WinFX (now .NET framework 3.0 I guess). It provides the kind of decoupling
I think you're looking for.
Jun 23 '06 #10

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

Similar topics

2
2137
by: skubik | last post by:
I'm curious as to whether it's possible to create a Form object and populate it with form element objects, strictly in Javascript, without the need to apply the form to a document. Essentially, I want to do this: tmpFormObj = new Form(); tmpFormObj.target = document.location; // For example. tmpFormObj.method = "POST";
3
2536
by: JavaConvert | last post by:
I would like to create form that simply hold textboxes that I log info to during the execution of a single-thread application. In Java, I found JFrame ideal for the task, but I can't recreate the same design with Forms. I can create the Form without Application.Run( ), but when debugging, I can't seem to see any text that gets AppendText'ed to the form. I've done some searching, but cannot find any samples or documentation that use Forms...
6
4363
by: Tarang Deshpande | last post by:
I would like to be able to create controls at run-time rather than at design time. Is there a function that I can override so that I can output the appropriate html code between when the <body> and </body> tags are outputed. I don't have to have web form controls but could just be plain html controls. Thanks
0
1411
by: Marc Callec | last post by:
I'm trying to create an instance of the CrystalReportViewer control within my class in an attempt to return the rendered HTML back to the consumer of the class. Because I haven't added the CrystalReportViewer control directly to a web page, but have instantiated in manually I've explicitly called the OnLoad, OnInt, OnPreRender and OnUnload in an attempt to get the control to be initialised correctly. Dim stringWrite As New...
1
1314
by: sheri | last post by:
I need help!! I am creating a form. I want to add a value from my table. The table name is COLDST. The fields I am working with are in this same table. I want to enter Product ID and have it populate the Description and Case Pack fields. I have tried to do it with a combo box on my form and can't get it to work.
1
1613
by: Vanyok | last post by:
Hi everyone :) I'm a newb to C-Sharp but more I learn about it - more I like it. I need some help please. I'm trying to find out to dynamically allocate form controls. For example I want to have 5 combo boxes on my form and I want to put the into an array. Can someone point me to some good guide on how to do it or posibly post 'how to' ? Thanks in advance.
1
1595
by: TopherB | last post by:
Hi, First let me say that my knowledge of HTML and Javascript is fairly limited. But I am stuck in a situation of trying to adapt a website's shopping cart to a new one. Here's the problem, the code contains thousands of 'Add to Cart' buttons that look almost identical to this HTML snippet spread across over hundred pages: <form> <p align="center"> <select name="package" size="1" style="width: 170" style="font-weight: 700"> <option...
2
2331
by: Haren786 | last post by:
VB6 Form resize diable user from manually resizing it?
1
5797
by: dufnobles via AccessMonster.com | last post by:
How can I manually save information entered on a form onto a table? The form information is derived from different tables. I want to inter the resulting information into another table. Please help. Thanks. -- Message posted via http://www.accessmonster.com
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.