473,404 Members | 2,187 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,404 software developers and data experts.

Sharing data between forms

I am trying to switch to C# from Delphi and I am having some trouble finding
some information. What I need to do should be simple but I have been through
a dozen books and done web searches that don't help me out at all. Delphi
had a data module that was shared between an applications forms but I don't
see any way to do this in C#.

Lets say I have two forms, the first with a data grid and the second with
field that should contain the data coresponding to the selected record in
the grid. The second form requires setting the query parameter before
showing the data. Because of the way that C# seems to work (each form has
it's own connection and data components) I don't understand how to get the
two forms or data sets to communicate with each other.

This seems like it should be a very common thing to do, is there an example
anywhere showing how to do this?

Nov 16 '05 #1
2 6883
Set a property or properties in each form and make them public. Set the
public property and then you can access it from any form.

Or , create a class with static properties...then set the property
corresponding tot he data you'll need. If you set them as public static,
they'll be visible by every object in the project.
"Red Green" <re*@green.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I am trying to switch to C# from Delphi and I am having some trouble finding some information. What I need to do should be simple but I have been through a dozen books and done web searches that don't help me out at all. Delphi
had a data module that was shared between an applications forms but I don't see any way to do this in C#.

Lets say I have two forms, the first with a data grid and the second with
field that should contain the data coresponding to the selected record in
the grid. The second form requires setting the query parameter before
showing the data. Because of the way that C# seems to work (each form has
it's own connection and data components) I don't understand how to get the
two forms or data sets to communicate with each other.

This seems like it should be a very common thing to do, is there an example anywhere showing how to do this?

Nov 16 '05 #2
OK I understand how to make a variable public and I have tested it.

The part I don't understand is how to get the value I need to set it to. If
the datagrid has the 3 rd row highlighted that corresponds to a record in
the dataset and a field in that record has the value that I need to get for
the parameter of the dependent query. In Delphi the current record in the
dataset bound to the grid is the one selected in the grid. Is this the case
in C# and if so how do I get that value?

In Delphi it would be
ThisVar := DM1.Qry1FieldName.Value;
DM1.Qry2.Parameters[1].Value := ThisVar;

Where DM1 is the name of the datamodule, Qry1 is the Ado query that is bound
to the datagrid and FieldName is the name of the Data Field with the value
required.

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Set a property or properties in each form and make them public. Set the
public property and then you can access it from any form.

Or , create a class with static properties...then set the property
corresponding tot he data you'll need. If you set them as public static,
they'll be visible by every object in the project.
"Red Green" <re*@green.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I am trying to switch to C# from Delphi and I am having some trouble

finding
some information. What I need to do should be simple but I have been

through
a dozen books and done web searches that don't help me out at all. Delphi had a data module that was shared between an applications forms but I

don't
see any way to do this in C#.

Lets say I have two forms, the first with a data grid and the second with field that should contain the data coresponding to the selected record in the grid. The second form requires setting the query parameter before
showing the data. Because of the way that C# seems to work (each form has it's own connection and data components) I don't understand how to get the two forms or data sets to communicate with each other.

This seems like it should be a very common thing to do, is there an

example
anywhere showing how to do this?


Nov 16 '05 #3

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

Similar topics

0
by: Paul Schouten | last post by:
I was wondering if anyone could help me with this... I am having problems sharing data between child forms. the setup is as follows: mainFrm <--- MDIForm |----> ViewFrm <----ChildForm |---->...
6
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= ...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
2
by: Mervin Williams | last post by:
I am using Infragistics UltraWebTab (a tab folder control for ASP.NET). My tab folder control will include five tab pages with a separate web form on each, and these web forms will share data. ...
1
by: Tod Birdsall, MCSD for .NET | last post by:
Hi All, I have two ASP.NET applications which I am trying to have share forms authentication. But I am running into problems. App A is an ASP.NET 2.0 Beta 2 application. App B is an ASP.NET...
3
by: Chris Thunell | last post by:
I have 2 forms, on 1 form i use the wizards to create a strong typed dataset with tables from an SQL database... and from that i can do stuff like: me.daEmployee.fill(me.dataset11.tblEmployee) ...
11
by: Nick | last post by:
Hello, Please pardon my ignorance as this is something I should know, but I'm a little unclear. I have an MDI based app. It is setup so the user opens a file and the main child form is created....
1
by: Bob Alston | last post by:
Having problems sharing an Access database on a Windows 2000 PC. The other PC is windows 98 (as I recall) but NOT windows 2000! The 2nd PC has a shortcut to the MDB on the primary PC. The MDB...
9
by: kirk | last post by:
I have program.cs, my "main" form and then a "settings" form. My "main" form existed for awhile and I had constants, instantiations, properties, etc within it created. I went to create my...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.