Dear Professionals,
I have recently been using the wonderful krypton toolkit and am trying
to use them in my small hobby application. I include this bit of info
as an aside really because i'm sure my question can be extrapolated to
the more general case, so here goes!
I have a box standard windows forms project. (File, New Project,
Windows Application, OK)
I have added a form2 to this project using the Add New Item button, and
then choosing Windows Form. So far so simple.
However I want to use a form from an existing project. I have two
versions of Visual Studio lets say A and B.
A - has the solution open that has a form in that I want to use.
B - has my live working project in it. I would like the form from
version A in B.
First I tried right clicking the form in the solution explorer of A,
and then pasting it into the solution explorer of B. That didn't work
however i got the message that 'The source file for this operation
cannot be found in this solution'.
So next I tried creating a new form in B. using Add new Item, and
choosing windows form. I copied the contents of the forms code in
question from solution A, and pasted this over the top of the newly
created forms code in version B, so that I had entirely replaced the
wizard generated code in version B with the form I actually wanted from
version A. I noticed that the form appearance now looked right, but
that none of the controls appeared on the form. So I went back to the
original form on version A that I was trying to replicate, and used
Edit Select All. I then went back into my half created form in version
B, and pasted these controls. Now my form in version B looked identical
to the form in version A. So I had thought I had triumphed!
If you are still with me thankyou very much, this isn't easy to explain
in words, so i'm sure it's even harder to understand!
However I have a problem in that I can not display my newly created
form!
At the moment my program.cs in version B (the version of Visual Studio
that has my live project i'm working with) has the following as it's
main method: -
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Form2 frm = new Form2();
if (frm.ShowDialog () == DialogResult.OK )
{
Application.Run (new Form2(frm.UserN ame));
}
}
The new form i've created using the above processes is called 'form3'
however if i change Form2 above to read Form3 and run the programme i'm
told that the 'type of namespace Form3' could not be found. I have
tried changing the case so that it reads form3, but this also doesn't
work. I have tried saving the solution, (CTRL SHIFT S = save all) and
it still doesn't work. Yet when I view solution explorer my form3 is
sitting pretty and smiling back at me, I can see it and it's listed as
form3 in the solution explorer.
Any ideas please why this isn't displaying would be greatly, greatly
appreciated!
Please excuse the diatribe above but I have re read and re read it, and
despite the fact that my need is fairly simple - (wanting to use a form
from another project in a new project) I couldn't find a terser way of
putting it!
Thankyou,
Gary. 3 8604
<ga********@myw ay.comwrote in message
news:11******** *************@a 3g2000cwd.googl egroups.com...
[...]
Please excuse the diatribe above but I have re read and re read it, and
despite the fact that my need is fairly simple - (wanting to use a form
from another project in a new project) I couldn't find a terser way of
putting it!
Even with your lengthy description, it's not clear to me what went wrong in
your attempt to copy and paste the form from one project to another. In
theory there should be no reason that wouldn't work, but of course you need
to make sure that you copy *everything*, and make sure that all the events
that were hooked up in the original form are hooked up properly in the
copied form.
The form is simply the designer part and the code part. The designer part
describes the visual layout of the form along with initial properties for
the form and contained controls, and the code is of course the code you
wrote to support the form. As long as you've completely copied both
correctly, there should be no problem.
That said, if you're reusing the form, and especially if you expect to reuse
it more than once, you may find that it makes more sense to simply keep the
form in its own project, and then reference that project by any other
project that wants to use the form. Of course, if you do this you'll
probably want to use more descriptive names than "Form2" and "Form3". But
the general technique is better for code reuse than simply copying and
pasting existing code.
Pete
Thankyou Pete, i'll try your method in future versions.
For anyone reading this with a similiar problem, the error was that I
was referencing the form as form3 in the program.cs main method,
(because this is how it was listed in solution explorer.)
However the form should have been referenced using projectname.for m ,
despite the fact that I had copied it into a new project.
Gary-
Peter Duniho wrote:
<ga********@myw ay.comwrote in message
news:11******** *************@a 3g2000cwd.googl egroups.com...
[...]
Please excuse the diatribe above but I have re read and re read it, and
despite the fact that my need is fairly simple - (wanting to use a form
from another project in a new project) I couldn't find a terser way of
putting it!
Even with your lengthy description, it's not clear to me what went wrong in
your attempt to copy and paste the form from one project to another. In
theory there should be no reason that wouldn't work, but of course you need
to make sure that you copy *everything*, and make sure that all the events
that were hooked up in the original form are hooked up properly in the
copied form.
The form is simply the designer part and the code part. The designer part
describes the visual layout of the form along with initial properties for
the form and contained controls, and the code is of course the code you
wrote to support the form. As long as you've completely copied both
correctly, there should be no problem.
That said, if you're reusing the form, and especially if you expect to reuse
it more than once, you may find that it makes more sense to simply keep the
form in its own project, and then reference that project by any other
project that wants to use the form. Of course, if you do this you'll
probably want to use more descriptive names than "Form2" and "Form3". But
the general technique is better for code reuse than simply copying and
pasting existing code.
Pete
<ga********@myw ay.comwrote in message
news:11******** *************@q 40g2000cwq.goog legroups.com...
[...]
However the form should have been referenced using projectname.for m ,
despite the fact that I had copied it into a new project.
For what it's worth, this suggests that you didn't really copy it correctly.
That is, you copied more than just the code that supports the form. You
copied the namespace declaration as well, putting the form into a different
namespace than the one the target project is using.
So, rather than changing your references to form to "projectname.fo rm", you
could have simply fixed the namespace declaration for the copied form to
match your project, and used the form normally.
Copy and paste is fraught with little gotchas like this. And of course, now
you have two copies of the exact same code, so when you find a bug in the
code, you'll have to remember to fix it in both places. Just a couple of
the reasons why copy and paste is bad, reuse by reference is good. :)
Pete This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Roy |
last post by:
Hi all,
I need to use a form from one application to another. I can do the followings:
1. Copy the form.vb file to the new project folder and add it to the project
as an existing form.
2. Create a new form in the project and copy the code from form.vb to this
new form.
3. Other (your suggestion)
What approach makes more sense?
|
by: Craig Kenisston |
last post by:
If I try to add existing *.cs files to my project the are copied my working
directory !
I want to keep some general purpose classes outside the projects in a single
place, so, if I improve a class it is reflected in all the projects.
Is that possible ?
|
by: VMI |
last post by:
I recently completed a Windows project that basically processes physical
addresses. In its simplest form, I would submit an address and the system
would then return it fixed. Now I need to do this in a web-based form.
For the Windows app, I have my GUI dll which sends the address to another
dll (it sends three strings) , which in turns sends...
|
by: foo |
last post by:
Hello,
I have a form that I developed in a small simple project. The form runs
fine by itself. When I try to create a new form that inherits from this
form, the machine goes off in the weeds for many minutes and throws off an
error 5 "Invalid procedure call or argument", and uses up all the machine
resources so Windows has to increase them...
|
by: Rod Gill |
last post by:
Hi,
I have a form that when opened in the designer appears of the screen. The
form selector can't be dragged (or resized) and if I scroll right and down
to centralise it the form simply jumps further away, completely leaving the
selector box area.
Any ideas? VS 2003 and VB.Net
This is a simple application at the moment but the form is...
| |
by: tony |
last post by:
Hello!!
Normally I use C# but we have a project that is creating a window control
library DLL that is done in C++.NET and that is here I have some problems
that I want to solve.
To be able to understand my question fully, I do the following.
1. Create a project that is a WindowControlLibrary called Test in C++.NET
in this project we...
|
by: kun1he2 |
last post by:
Hmm... reusing VB.NET Form dialogs in other VB.NET projects seems very
straight forward.
However, I'm now trying to reuse these dialogs within an existing
C-based app.
The VB.NET project has already been configured for registration for COM
interop, so next question is how do I get retrieve/invoke the dialog's
interfaces/properties?
|
by: =?Utf-8?B?d2lubGlu?= |
last post by:
Hello
Using VS 2005 VB.net when a class library gets created you can right click
the project and add a Windows Application and then set it as the "startup
project" then in the Windows application you can add a reference to that
class library in the project by right clicking the Windows Application and
selecting "Add Reference" and you will...
|
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. ...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |