Autor Beitrag
Questioneer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mi 29.10.08 14:09 
Hi Leute,

ich habe einen simplen Butten der das generi9erte Ereignis Button_Click besitzt:

ausblenden C#-Quelltext
1:
2:
3:
        private void Button_Click(object sender, EventArgs e)
        {
        }


Diesem Ereignis möchte ich aber noch einige Parameter mehr als nur die Defaultparameter übergeben und möchte es zu diesem Zweck überschreiben:

ausblenden C#-Quelltext
1:
2:
3:
        private void Button_Click(object sender, EventArgs e, int iWert1, string strWert2)
        {
        }


ich finde dazu leider nichts in meinem Buch, könnt Ihr mir da weiterhelfen ???

Vielen Dank für eure Mühe und Hilfe !
Gruß
Questioneer
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 29.10.08 14:18 
Woher sollen denn die Parameter kommen? Der automatische Aufruf eines Ereignisses kann ja nicht "wissen" was er dann dort hineinschreiben müsste. :nixweiss:

Was hast du damit vor? Das musst du anders lösen.
Questioneer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mi 29.10.08 14:42 
Hi Jaenicke,

Zitat:
Woher sollen denn die Parameter kommen?


Ja klar kann er das nicht wissen die parameter wollte ich übergeben aus einer anderen Fnkt. heraus, oder geht das gar nicht mit dem überschreiben ?


Gruß
Questioneer
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 29.10.08 14:55 
Was hat das für einen Sinn? Lagere das was im Event passiert in eine ganz eigene Funktion aus, diese kannst du dann frei aufrufen, auch aus dem Event heraus.
Questioneer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mi 29.10.08 15:41 
Hi Jaenicke,


meinst Du das so ??? :

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
        private void Button_Click(object sender, EventArgs e)  
        {  
            DasPassiert(......)
        } 

        private void DasPassiert(......)
        {

        }


Die Parameter von DasPassiert(......) nonnen halt von überallher geändert werden.


Gruß
Questioneer
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 29.10.08 15:56 
Ja, so meine ich das, so kannst du die Parameter frei bestimmen und dann die Funktion aufrufen.
Questioneer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mi 29.10.08 16:02 
Stimmt so isses am besten !
;)
Questioneer