🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #455

Przekazywanie wartości między formami

#455
From: eclipse
Date: Sun, 01 Feb 2004 12:40
34 lines
1783 bytes
Witam.

Banalne to zapewne, ale utknąłem na tym kompletnie :)

Mam w jednym namespace 2x Window Form. Przykładowo - jeden jest głównym
oknem aplikacji, drugi - np. oknem preferencji. Okno to wywołuję bez problemu:

Form optionsForm = new OptionsForm();
optionsForm.ShowDialog();

No i teraz jest problem: w jaki sposób dobrać się do wartości wprowadzonych
w tym oknie? Załóżmy, że jest tam TextBox w którym wprowadzono jakiś tekst.
W OptionsForm.cs mam tak:

private string a; // ustawiany przy wywołaniu TextBox.TextChanged

public string A
{
	get { return a; }
}

Teraz w MainForm.cs próbuję się dobrać do tego stringa w taki sposób:

label1.Text = optionsForm.A;

Rozwiązanie to oczywiście nie działa (D:\Work\Visual Studio
Projects\Test02\MainForm.cs(104): 'System.Windows.Forms.Form' does not
contain a definition for 'A').

Pomożcie, poproszę :)

-- 
[ eclipse(at)post.pl ]  [ +48 609 676 178 ]
[ ..but the sun is eclipsed by the moon.. ]
Technical Details
Message-ID: <8b9f1424f868ebc4d7c164c37c922ab1@total.eclipse>
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed.gazeta.pl!news.ipartners.pl!news.home.net.pl!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <8b9f1424f868ebc4d7c164c37c922ab1@total.eclipse>
Date: Sun, 01 Feb 2004 13:40:12 +0100
From: eclipse <ecl...@post.pl>
User-Agent: Mozilla Thunderbird 0.5a (Windows/20040128)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: alt.pl.comp.lang.csharp
Subject: Przekazywanie wartości między formami
NNTP-Posting-Host: 213.76.51.185
X-Trace: news.home.net.pl 1075644661 213.76.51.185 (1 Feb 2004 15:11:01 +0100)
Organization: home.pl news server
Lines: 34
X-Authenticated-User: ecl...@post.pl
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed.gazeta.pl!news.ipartners.pl!news.home.net.pl!not-for-mail
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit