473,569 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object passing with Windows Forms

I do the following:

1 - create a parent form called Options & put a listbox on the form lstURLs.
2 - create a child form called OptionsAdd
3 - in the parent form I create a line "Form dlgOptionsAdd = new
OptionsAdd(ref this.lstURLs);"
4 - in the the child form I modify "public OptionsAdd() {}" to be "public
OptionsAdd(ref ListBox lstURLs){}"

When I do this I'm only able to access the ListBox in the OptionsAdd method
of the OptionsAdd form.

How do I make the ListBox accessible to all the functions in the OptionsAdd
form?

Thanks,
Nov 17 '05 #1
2 1270
Hi eXtreme,

Welcome to MSDN newsgroup.
As for the accessing controls from different form, and sharing data
problem, I think we can use the following approachs to resolve it:

1. For Data displaying / manipulating GUI problem, we're recommended to
sparate the UI and the data. Typically, many ones are using the MVC
design-pattern for such scenario:

#Implementing MVC Design Pattern in .NET
http://www.c-sharpcorner.com/Code/20.../MVCDesign.asp

#UIPAB Part 2 : MVC, UIPAB Essentails and Demo
http://www.codeproject.com/dotnet/UIPAB2.asp

For your scenario, I think we can define a certain Data container class
which hold the underlying datas (which will be used to fill the controls on
the form). This class has some member properties which hold the reference
of the List, Array, DataSet/DataTable.....

Then, in our Form/SubForm's constructor, we will pass an instance of this
class. And when we need to displaying data on the form, we just retrieve
the data from that member instance and bind data to the controls on the
form. Also, when open a sub form, we provide the member property in the
parent form in the construction of the sub form(sub form also has a certain
field/propety to hold this reference). Thus, when user take action on the
subform to modify data, we just update that object instance in subform's
code and the parent form can directly retrieve the updated fresh data from
the same instance. How do you think of this?

If there're anything unclear, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #2
Hi eXtreme,

Have you got any further progress on resolving the problem or does the
suggestions in my last reply helped a little?
If there're any thing else we can help, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #3

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

Similar topics

8
3951
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
2
2390
by: Roby Eisenbraun Martins | last post by:
Hi, My name is Roby Eisenbraun Martins, I am a C++, VB and NET developer. I am working with a NET 2002 project right now and I am receiving this uncommon "OutOfMemory" error message when I try to load a form object ( new frmMain() ). In debug mode, the "Load" form method is executed but it crashes when it tries to set a DataTable from a...
3
3160
by: Poewood | last post by:
Okay here are four classes for a pocket pc program: Input, fpositional, ComboBoxArray and TextBoxArray. The "input" class is the form. I use the fpositional class to handle most of the functions for the objects on the form, in addition the The objects are created in the fpositional class and affixed to the Input form through the fpositional...
7
9975
by: Clint Herron | last post by:
Howdy! I posted this question on CSharpCorner.com, but then realized I should probably post it on a more active newsgroup. This will be my only cross-post. I'm creating a game engine, and using CodeDOM for my scripting needs (I realize I could use yacc or something else, but I wanted to try using CodeDOM -- this is more of an exercise for...
0
1728
by: Patrick | last post by:
This is a C# post. I'm using VB.NET to create an add-in for the Google Sidebar, and have implemented the OnDetailsView method. NOTE : I've come across this same problem (error message) even in C#. I tried placing a label control and setting the reference of this new lable into the 'details_control' parameter. This worked.
6
3245
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A query-string flag is used to indicate to the page whether it should instantiate a new instance of the object or access an existing instance from the...
10
4299
by: Sebastian Santacroce | last post by:
Hi, If I want to pass a form (forms I have created) to a function what would I set the declaration as for example Dim p as existingForm OpenForm (p, existingForm)
0
1897
by: Deepak C.G via .NET 247 | last post by:
I want to dispose the image object in my child form, unless I won't dispose this object i can't delete the image file in my folder. I get this error in MDIparent form "An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll" "Additional information: Invalid parameter used." Here is my code:-
15
26238
by: mr.peteryu | last post by:
Hi, Can someone explain the idea behind casting to an interface? For example: -> I have an IInterface that contains a Read() method. -> I have an object "obj" that implements IInterface. Why would someone do the following and what does it mean?
14
2009
by: James | last post by:
I am trying to a add a method to a helper class library I built that will fade out the current form. My code is this: public void fade(object currentForm) { int z = 0; for(double i=1.0; i> 0; i-=.1) { currentForm.Opacity = i; while(z<10000)
0
7694
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...
0
7921
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. ...
0
8118
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...
1
7666
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...
1
5504
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...
0
5217
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...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2107
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
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.