Autor Beitrag
C#David
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mi 16.05.18 15:15 
Hey Leute

als nächste möchte ich die Hintergrundfarbe von einer beliebigen Form ändern. Dazu verwende ich eine Funktion "SetBackgroundColor()", welche beim Klickevent einer der Buttons aufgrunfen werden kann. Aus irgendeinen Grund funzt das nicht (: ... über das Eigenschaftenfesnter lässt es sich hingegen manuell ändern:

ausblenden C#-Quelltext
1:
2:
3:
4:
public void SetBackgroundColor()
{
  this.BackColor = System.Drawing.Color.Red;
}

Was ist daran verkehr? Besten Dank!

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
lapadula
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 180
Erhaltene Danke: 10



BeitragVerfasst: Mi 16.05.18 16:15 
Rufst du die Methode auch auf, bzw. springt er in das Klick-Event? Bei mir funktioniert es wunderbar.
C#David Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mi 16.05.18 16:30 
Die Funktion wird beim Klickevent einer der Button erfolgreich aufgerufen. Habe es auch schon mit "this.SetBackgroundColor()" probiert...auch erfolglos??

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
 private void button2_Click(object sender, EventArgs e)
        {
            Size = this.Size;
            //Öffnen einer neuen Windows-Form            
            frm3.WindowState = FormWindowState.Maximized;
            //frm3.TopLevel = true;
            frm3.MdiParent = this;
            frm3.Show();
            //Button 1-3 unsichtbar werden lassen
            button1.Visible = false;        
            button2.Visible = false;
            button3.Visible = false;

            SetBackgroundColor(); 
            //this.SetBackgroundColor(); 
        }


Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
lapadula
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 180
Erhaltene Danke: 10



BeitragVerfasst: Mi 16.05.18 16:51 
Wenn du die Hintergrundfarbe der "frm3" ändern willst, dann musst du diese auch ansprechen.

ausblenden C#-Quelltext
1:
frm3.BackColor = System.Drawing.Color.Red;