Thread View: alt.pl.comp.lang.csharp
4 messages
4 total messages
Started by eclipse
Sun, 01 Feb 2004 12:40
Przekazywanie wartości między formami
Author: eclipse
Date: Sun, 01 Feb 2004 12:40
Date: Sun, 01 Feb 2004 12:40
34 lines
1783 bytes
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.. ]
Re: Przekazywanie wartości między formami
Author: eclipse
Date: Sun, 01 Feb 2004 15:22
Date: Sun, 01 Feb 2004 15:22
12 lines
1172 bytes
1172 bytes
Tako rzecze eclipse: > Banalne to zapewne, ale utknąłem na tym kompletnie :) Już wiem :) A tu jest rozwiązanie: http://www.codeproject.com/csharp/TwoFormObjectPass_Package.asp -- [ eclipse(at)post.pl ] [ +48 609 676 178 ] [ ..but the sun is eclipsed by the moon.. ]
Re: Przekazywanie wartości między formami
Author: peeles
Date: Sun, 01 Feb 2004 15:52
Date: Sun, 01 Feb 2004 15:52
3 lines
982 bytes
982 bytes
> Form optionsForm = new OptionsForm(); OptionsForm optionsForm = new OptionsForm();
Re: Przekazywanie wartości między formami
Author: eclipse
Date: Sun, 01 Feb 2004 17:32
Date: Sun, 01 Feb 2004 17:32
11 lines
1162 bytes
1162 bytes
Tako rzecze peeles: >>Form optionsForm = new OptionsForm(); > OptionsForm optionsForm = new OptionsForm(); No tak.. Dziękuję :) -- [ eclipse(at)post.pl ] [ +48 609 676 178 ] [ ..but the sun is eclipsed by the moon.. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads