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.

c# dynamische buttons

Empfohlene Antworten

hi

arbeite mich grad ein bisschen in c# ein; hab jetzt ein prog erstellt, was bei laden der form buttons erstellt. diese buttons haben auch eine onclick-methode.

meine frage an euch:

wenn ich auf einen button klicke und die methode aufgerufen wird, wie finde ich heraus welcher button gedrückt wurde, bzw. wie kann ich den button ansprechen???

ein bissle quellcode zur orientierung:

Button[,] Feld = new Button[4,4];

const int gr = 50;

private void button_Click(object sender, System.EventArgs e){

//hier ist das problem

}

private void Form1_Load(object sender, System.EventArgs e){

for (int x = 1; x <= 3; x++){

for (int y = 1; y <= 3; y++) {

Feld[y,x] = new System.Windows.Forms.Button();

Feld[y,x].Click += new System.EventHandler(button_Click);

}

}

}

mfg silly

guggst du hier:

private void button_Click([color=red]object sender[/color], System.EventArgs e){ 

//hier ist das problem

}

machst du so:
private void button_Click([color=red]object sender[/color], System.EventArgs e){ 

//hier ist die lösung (Stichwort: [color=blue]Boxing[/color])

((System.Windows.Form.Button)[color=red]sender[/color]).Text = "neuer Text";

}

jup es funzt thx

mfg silly

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.