Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

die Übrschrift ist wohl nicht so günstig gewählt, aber mir fällt nichts besseres ein.

Ich hab zwei Forms (Form1 und Form2) und noch eine. Ich öffne Form2 mit Form1 (also ein button):



Form2^ form2 = gcnew Form2();

form2->ShowDialog();


und nun wollte ich im Form 2 einem Button eine Funktion öffnen, die in Form1 enthalten ist und auch da laufen soll (die Funktion füllt etwas in ein DataGrid und das DataGrid ist nunmal in Form1). jedoch ohne dass ich Form2 schließen muss. Ich hab mir das so gedacht:


private: System::Void buttonQueryOK_Click(System::Object^  sender, System::EventArgs^  e) {


	 Form1^ form1 = gcnew Form1();

	 form1->loadQuery();


}


klappt aber nicht...

Danke schonmal...

Gruss

Natürlich nicht, du erstellst ja eine neue Form1. Du brauchst aber die Instanz von Form1 welche deine Form2 geöffnet hat.

Eine Möglichkeit wäre den Konstruktor von Form 2 so anzupassen das du die Instanz von Form1 übergeben kannst und dann kannst du darüber einfach deine Methode aufrufen...

für mich klingt das ein bisschen kompliziert. (bin anfänger)

wie kann ich denn die intanz von Form1 im Konstruktor von Form2 übergeben?

  • 2 Wochen später...

das klappt nicht so ganz...


public ref class Form2 : public System::Windows::Forms::Form

{

private: Form1 form1;

public:

	Form2(Form1 form1)

	{

		this->form1 = form1;

		InitializeComponent();

	}

}

(mein Programm heißt getwindowrect) Fehler:

1>c:\vsprojects\getwindowrect\getwindowrect\Form2.h(24) : error C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'form1'

1>c:\vsprojects\getwindowrect\getwindowrect\Form2.h(24) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht unterstützt.

1>c:\vsprojects\getwindowrect\getwindowrect\Form2.h(24) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht unterstützt.

1>c:\vsprojects\getwindowrect\getwindowrect\Form2.h(26) : error C2061: Syntaxfehler: Bezeichner 'Form1'

1>c:\vsprojects\getwindowrect\getwindowrect\Form2.h(28) : error C2039: 'form1': Ist kein Element von 'getWindowRect::Form2'

1>        c:\vsprojects\getwindowrect\getwindowrect\Form2.h(22): Siehe Deklaration von 'getWindowRect::Form2'

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.