473,699 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visibility of an object

I have in a form a SqlConnection and a SqlCommand but I also want to use
them in form shown as DialogForm. I declared the objects as public but I
don't know how to go on.

Thank you.
Nov 16 '05 #1
3 1362
Hi,

You have to pass a reference from the current form to the new form,
something like this:

Form2 f2 = new Form2( this ); // here I pass the reference to the current
form, where the Sql* are declared

f2.ShowDialog() ;

This is how Form2 looks like
class Form2{
Form1 parent

public Form2( Form1 parent){
this.parent = parent;
}

then in the Form2 you can use

parent.SqlComma nd , etc

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Alberto" <al*****@nospam .com> wrote in message
news:uh******** ******@tk2msftn gp13.phx.gbl...
I have in a form a SqlConnection and a SqlCommand but I also want to use
them in form shown as DialogForm. I declared the objects as public but I
don't know how to go on.

Thank you.

Nov 16 '05 #2
I finally did it passing at the constructor of the form2, references to the
connection and command objects.
Thanks anyway.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
escribió en el mensaje news:eV******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

You have to pass a reference from the current form to the new form,
something like this:

Form2 f2 = new Form2( this ); // here I pass the reference to the current
form, where the Sql* are declared

f2.ShowDialog() ;

This is how Form2 looks like
class Form2{
Form1 parent

public Form2( Form1 parent){
this.parent = parent;
}

then in the Form2 you can use

parent.SqlComma nd , etc

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Alberto" <al*****@nospam .com> wrote in message
news:uh******** ******@tk2msftn gp13.phx.gbl...
I have in a form a SqlConnection and a SqlCommand but I also want to use
them in form shown as DialogForm. I declared the objects as public but I
don't know how to go on.

Thank you.


Nov 16 '05 #3
Hi alberto,

That is also a solution :)

Now, what I advise you is to use a aux class to hold these objects , if you
make this class a singleton it will be MUCH easier to you to use them,
otherwise you will have to pass them around to any other form that you use.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Alberto" <al*****@nospam .com> wrote in message
news:uH******** *****@TK2MSFTNG P11.phx.gbl...
I finally did it passing at the constructor of the form2, references to the connection and command objects.
Thanks anyway.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
escribió en el mensaje news:eV******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

You have to pass a reference from the current form to the new form,
something like this:

Form2 f2 = new Form2( this ); // here I pass the reference to the current form, where the Sql* are declared

f2.ShowDialog() ;

This is how Form2 looks like
class Form2{
Form1 parent

public Form2( Form1 parent){
this.parent = parent;
}

then in the Form2 you can use

parent.SqlComma nd , etc

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Alberto" <al*****@nospam .com> wrote in message
news:uh******** ******@tk2msftn gp13.phx.gbl...
I have in a form a SqlConnection and a SqlCommand but I also want to use them in form shown as DialogForm. I declared the objects as public but I don't know how to go on.

Thank you.



Nov 16 '05 #4

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

Similar topics

12
3927
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with both single quotes and no single quotes, but it doesn't work either way. What am I doing wrong? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById('weblogs').style.visibility='hidden';
1
1795
by: lkrubner | last post by:
In the first version of this function, I only test for true or false, on a global var, without limiting that true or false to the id of a particular item. What this meant was that if you were using this function for several items on a page, sometimes you had to click twice and other times you only had to click once, because sometimes visibility was false though you were clicking on an item that was true. So then I started adding the id's...
8
3372
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an actual program. To me "scope" of the name of a function or object are the general rules for the areas of a program that can through a declaration, have "visibility."
1
1449
by: Mark Denardo | last post by:
I stumbled across a weird problem that I don't seem to understand and was wondering if anyone could help explain why it is occurring: Basically I have set up a client/server application where the client and server communicate via a NetworkStream. My problem is on the Client side. The Client's "Main Thread" starts up a form (Form1) which then invokes a new thread I'll label as "Listening_Thread". This thread's sole purpose is to...
4
3192
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can get public members but not protected, private, static members"
8
1475
by: khalprin | last post by:
Hello, I'm trying to create a component that will be used from .net clients and COM clients. I've got an object model that looks something like this: ISystem IRuntime IConfiguration ICollectionOfConfigurableThings IConfigurableThing
3
2462
by: RitualDave | last post by:
This compiles and runs successfully in VS2005: ref class A { private: ~A() { this->!A(); } // private! !A() { } // private! }; ....
11
2628
by: -D- | last post by:
How can I turn the visibility of the xml control on or off? <%@ Control Language="c#" AutoEventWireup="false" Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <table cellSpacing="0" cellPadding="0" border="0"> <colgroup span="1" align="left" width="50%"> </colgroup> <colgroup span="1" align="right" width="50%"> </colgroup>
5
1268
by: =?UTF-8?B?TWFydGluIFDDtnBwaW5n?= | last post by:
Hello, I´ve a general question about the visibility and modification of an object. I will try to explain it in my code, where I have the problem: DocumentList dList = initDocuments(thesaurus); for (int i = 0; i < testRuns_; i++)
2
1854
by: Jamey Bon | last post by:
I am a C# newbie. I am having a tough time with several issues of scope and visibility. In short, why can't I see any of the elements of Form1 (the base form generated by the "Windows Application Project Wizard") from anywhere else in my project? For example, why can I not change the text of a TextBox control from Main() (which is, by default, in the Program class) even after I have set its visibility to public in Form1? Furthermore,...
0
8687
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
9174
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
8883
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6534
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
5874
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
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
2347
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.