Autor Beitrag
MartinBush
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Do 03.07.08 18:27 
Hallo,

ich kann nun Klassenvariablen ändern aber wie geht das bei Methoden?

Ich möchte das für alle Buttons beim Enter drücken dieselbe Aktion ausgeführt wird wie beim Klicken.

Für einen Button bekomme ich das hin.


P.S: PocketPC Applikation

Mfg Martin
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.07.08 18:38 
Du weißt doch schon, wie man etwas für alle Buttons macht :nixweiss:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
MartinBush Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Fr 04.07.08 13:40 
Jup wenn es um estwas ändern geht - aber wie rufe ich da etwas auf?

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
 protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                ...Click ausführen...
                e.Handled = true;
            }
            base.OnKeyPress(e);
        }



So mache ich es für einzelne Buttons:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
        private void button_menu_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            { button_menu_Click(this, EventArgs.Empty); }
        }
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 04.07.08 14:13 
Ich kann's gerade nicht kontrollieren, aber wenn es fürs KeyPress-Ereignis die Methode OnKeyPress gibt, sollte es für das Click-Ereignis die Methode OnClick geben. Die solltest Du dann in OnKeyPress aufrufen können. :-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
MartinBush Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mo 07.07.08 16:08 
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
        protected override void  OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                OnClick(e);
            }
            
            base.OnKeyPress(e);
        }


Jup danke war kein Problem