473,387 Members | 1,611 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.

Duplicate A Form Object - Please Help

I am new to the .Net environment, so please bear with me.

I am passing a form object (e.g. formA) to an existing form (e.g. formB) by setting a property value defined in formB to hold the formA object. Please keep in mind that formB is defined in a separate library project.

I then display formB. Once formB is displayed, I have code in a double click event procedure in formB to display formA by getting the form object throught the property definition described above.

The code works perfectly fine initially displaying formA; however if formA is closed, I cannot redisplay it from the double click event procedure. I guess that by closing formA, I'm apparently destroying the object that I'm getting from the formB's property value. I presume that the object being set in the property value is a reference to when formA was originally instanciated and not a copy of formA.

Is there a way of making a copy of formA from within formB? Or is there a way re-instanciating formA from within formB? Please keep in mind that formB is in a separate library project and as such doesn't know about the formA type. As such I can't simply say:

Dim formA as New formB.

Any help would be incredibly appreciated.

Thanks
Ned
Nov 20 '05 #1
3 2206
This is what I think - if you close down the form, you still have a
reference to the form object. you simply need to call the Show() of the form
once again and you should be able to display the form however many times you
want to. I dont think you should need to make a copy of FormA - that would
be a waste. I'm not sure what code you have in your double click event which
would cause it to load the first time fine and not after that. Are you
setting the reference of FormA to nothing after you're done with form? That
could be problem. It'll be easier if you post your code how you are getting
the reference to FormA in the first place (your property) and code in your
double click event.
Imran.

"BakelNB" <Ba*****@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
I am new to the .Net environment, so please bear with me.

I am passing a form object (e.g. formA) to an existing form (e.g. formB) by setting a property value defined in formB to hold the formA object.
Please keep in mind that formB is defined in a separate library project.
I then display formB. Once formB is displayed, I have code in a double click event procedure in formB to display formA by getting the form object
throught the property definition described above.
The code works perfectly fine initially displaying formA; however if formA is closed, I cannot redisplay it from the double click event procedure. I
guess that by closing formA, I'm apparently destroying the object that I'm
getting from the formB's property value. I presume that the object being set
in the property value is a reference to when formA was originally
instanciated and not a copy of formA.
Is there a way of making a copy of formA from within formB? Or is there a way re-instanciating formA from within formB? Please keep in mind that formB
is in a separate library project and as such doesn't know about the formA
type. As such I can't simply say:
Dim formA as New formB.

Any help would be incredibly appreciated.

Thanks
Ned

Nov 20 '05 #2
Hey Imran,
I appreciate your reply. I’m actually using the show method to display FormA. The first time the code in the double click event executes, FormA displays perfectly and the code in FormA’s load event exeutes. Once FormA is displayed and assuming it’s not closed executing the show method to display FormA appears to do nothing which is what is expected because FormA is already displayed. What I want to do is close the form if it’s already displayed and show it again so the code in the form’s load event gets executed. That’s when I started to have understand the original problem described in my post. That is once I close the form, I can’t display it again.

I think the problem has to do with the “Type” that I’m defining the form has. I’m using the generic type “Form” to pass in the original form reference as opposed to using the specific form’s form type. I’m doing this because I want to be able to pass in different forms that will get displayed.

I’ve included the code in my double click event. I appreciate you looking into this.

Private Sub lstView_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstView.DoubleClick
'************************************************* ****
' Display the Deal details form
'************************************************* *****
Dim item As ListViewItem
Dim subitem As ListViewItem.ListViewSubItem
Dim frm As Form 'Form object

'************************************************* *****
' Display the form object that was passed to the Deal Selector
'************************************************* *****
Me.DealId() = Me.lstView.SelectedItems(0).SubItems(2).Text 'Set the deal selector's dealid property
frm = Me.FormToDisplay 'Get the form from the property to display
frm.MdiParent = Me.ParentForm() 'Set the form's parent property to the current parent
frm.Show() 'Display the form

I've also tried diming the "frm" object as New Form. That doesn't work either. Any assistance would be incredibly appreciated.

Thanks
Ned
"BakelNB" wrote:
I am new to the .Net environment, so please bear with me.

I am passing a form object (e.g. formA) to an existing form (e.g. formB) by setting a property value defined in formB to hold the formA object. Please keep in mind that formB is defined in a separate library project.

I then display formB. Once formB is displayed, I have code in a double click event procedure in formB to display formA by getting the form object throught the property definition described above.

The code works perfectly fine initially displaying formA; however if formA is closed, I cannot redisplay it from the double click event procedure. I guess that by closing formA, I'm apparently destroying the object that I'm getting from the formB's property value. I presume that the object being set in the property value is a reference to when formA was originally instanciated and not a copy of formA.

Is there a way of making a copy of formA from within formB? Or is there a way re-instanciating formA from within formB? Please keep in mind that formB is in a separate library project and as such doesn't know about the formA type. As such I can't simply say:

Dim formA as New formB.

Any help would be incredibly appreciated.

Thanks
Ned

Nov 20 '05 #3
On Thu, 1 Jul 2004 05:30:01 -0700, NeddyRock wrote:

Don't *close* the form, *hide* it. If you need to call the code in the
load event, place that code in a separate sub so you can call it again.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 20 '05 #4

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

Similar topics

1
by: marx | last post by:
I have a bit of a problem and any help would be much appreciated. Problem: I have two dropdown list boxes with same data(all data driven). These are used for two separate entries. For every...
2
by: Paolo | last post by:
Hello, I am again submitting my question since have not had much luck with my previous posting. What I am trying to do is duplicate data from one table to another. I know is not the correct...
6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
0
by: Suler Abou | last post by:
Hi, I'm having a problem with an SQL statement, I have a statement that goes like this: "INSERT INTO table VALUES('TransID','CID',etc...);" it basically adds new data to a table. When the...
0
by: NeddyRock | last post by:
I am new to the .Net environment, so please bear with me. I am passing a form object (e.g. formA) to an existing form (e.g. formB) by setting a property value defined in formB to hold the formA...
1
by: bruce24444 | last post by:
I am designing a database to use a work to assign files to certain people. Form includes Date textbox, File Number textbox, File Type combobox and Assigned To combobox. The form is working fine and...
2
by: Harry Haller | last post by:
I want to duplicate the form data, edit it to remove some items (such as __EVENTTARGET, __EVENTVALIDATION, etc) and save it to a log. How can I make a duplicate (editable) copy of the Form...
6
by: Dave | last post by:
I really don't like the users getting an unhandled expception page, and I'm still to new with ASP.Net and C#. So please accept my appology for the 2 part question. SqlException (0x80131904) ...
1
by: VinArt | last post by:
MS Acc 2003, XP Thank you in advance for any help. I have tables called "Makeup" and "Lines". Each makeup can have multiple lines. Goal is to create a new "makeup" with identical "lines"...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.