Hallo,
die Designer.cs meiner Form gibt bei der Codestelle this.ResumeLayout(false); einen System.StackOverFlow Fehler aus.
Hier der Designer Code:
Spoiler anzeigen
Es lief alles doch als ich den 3 neuen Buttons in einer anderen Form ein KlickEvent gab (dass über eine Funktion der Hauptform in der InfoForm Bilder bzw. Labels ändert) kam der Fehler
Hier der Code der Shop Form
Spoiler anzeigen
die Designer.cs meiner Form gibt bei der Codestelle this.ResumeLayout(false); einen System.StackOverFlow Fehler aus.
Hier der Designer Code:
C#-Quellcode
- namespace MisteryDungeon
- {
- partial class Info
- {
- /// <summary>
- /// Erforderliche Designervariable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// Verwendete Ressourcen bereinigen.
- /// </summary>
- /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region Vom Windows Form-Designer generierter Code
- /// <summary>
- /// Erforderliche Methode für die Designerunterstützung.
- /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
- /// </summary>
- private void InitializeComponent()
- {
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.label1 = new System.Windows.Forms.Label();
- this.pictureBox3 = new System.Windows.Forms.PictureBox();
- this.pictureBox4 = new System.Windows.Forms.PictureBox();
- this.pictureBox5 = new System.Windows.Forms.PictureBox();
- this.pictureBox6 = new System.Windows.Forms.PictureBox();
- this.pictureBox7 = new System.Windows.Forms.PictureBox();
- this.pictureBox8 = new System.Windows.Forms.PictureBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).BeginInit();
- this.SuspendLayout();
- //
- // pictureBox1
- //
- this.pictureBox1.Location = new System.Drawing.Point(63, 37);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(20, 20);
- this.pictureBox1.TabIndex = 0;
- this.pictureBox1.TabStop = false;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(89, 41);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(13, 13);
- this.label1.TabIndex = 2;
- this.label1.Text = "0";
- //
- // pictureBox3
- //
- this.pictureBox3.Location = new System.Drawing.Point(8, 12);
- this.pictureBox3.Name = "pictureBox3";
- this.pictureBox3.Size = new System.Drawing.Size(20, 20);
- this.pictureBox3.TabIndex = 4;
- this.pictureBox3.TabStop = false;
- //
- // pictureBox4
- //
- this.pictureBox4.Location = new System.Drawing.Point(34, 12);
- this.pictureBox4.Name = "pictureBox4";
- this.pictureBox4.Size = new System.Drawing.Size(20, 20);
- this.pictureBox4.TabIndex = 5;
- this.pictureBox4.TabStop = false;
- //
- // pictureBox5
- //
- this.pictureBox5.Location = new System.Drawing.Point(60, 12);
- this.pictureBox5.Name = "pictureBox5";
- this.pictureBox5.Size = new System.Drawing.Size(20, 20);
- this.pictureBox5.TabIndex = 6;
- this.pictureBox5.TabStop = false;
- //
- // pictureBox6
- //
- this.pictureBox6.Location = new System.Drawing.Point(86, 12);
- this.pictureBox6.Name = "pictureBox6";
- this.pictureBox6.Size = new System.Drawing.Size(20, 20);
- this.pictureBox6.TabIndex = 9;
- this.pictureBox6.TabStop = false;
- //
- // pictureBox7
- //
- this.pictureBox7.Location = new System.Drawing.Point(112, 12);
- this.pictureBox7.Name = "pictureBox7";
- this.pictureBox7.Size = new System.Drawing.Size(20, 20);
- this.pictureBox7.TabIndex = 8;
- this.pictureBox7.TabStop = false;
- //
- // pictureBox8
- //
- this.pictureBox8.Location = new System.Drawing.Point(138, 12);
- this.pictureBox8.Name = "pictureBox8";
- this.pictureBox8.Size = new System.Drawing.Size(20, 20);
- this.pictureBox8.TabIndex = 7;
- this.pictureBox8.TabStop = false;
- //
- // Info
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(166, 66);
- this.ControlBox = false;
- this.Controls.Add(this.pictureBox6);
- this.Controls.Add(this.pictureBox7);
- this.Controls.Add(this.pictureBox8);
- this.Controls.Add(this.pictureBox5);
- this.Controls.Add(this.pictureBox4);
- this.Controls.Add(this.pictureBox3);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.pictureBox1);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "Info";
- this.Text = "Info";
- this.Load += new System.EventHandler(this.Info_Load);
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- public System.Windows.Forms.Label label1;
- public System.Windows.Forms.PictureBox pictureBox3;
- public System.Windows.Forms.PictureBox pictureBox4;
- public System.Windows.Forms.PictureBox pictureBox5;
- public System.Windows.Forms.PictureBox pictureBox6;
- public System.Windows.Forms.PictureBox pictureBox7;
- public System.Windows.Forms.PictureBox pictureBox8;
- private System.Windows.Forms.PictureBox pictureBox1;
- }
- }
Es lief alles doch als ich den 3 neuen Buttons in einer anderen Form ein KlickEvent gab (dass über eine Funktion der Hauptform in der InfoForm Bilder bzw. Labels ändert) kam der Fehler
Hier der Code der Shop Form
C#-Quellcode
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace MisteryDungeon
- {
- public partial class Shop : Form
- {
- Dungeon Dungeon = new Dungeon();
- public Shop()
- {
- InitializeComponent();
- }
- private void Shop_Load(object sender, EventArgs e)
- {
- this.button1.Image = Image.FromFile("shop/heart_1.png");
- this.button2.Image = Image.FromFile("shop/heart_3.png");
- this.button3.Image = Image.FromFile("shop/heart_full.png");
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (Dungeon.Goldmünzen >= 15)
- {
- Dungeon.Goldmünzen -= 15;
- Dungeon.Leben += 1;
- if (Dungeon.Leben > 6)
- {
- Dungeon.Leben = 6;
- }
- Dungeon.InfoSetzen();
- }
- else
- {
- MessageBox.Show("Du brauchst 15 Goldmünzen!", "Du hast nicht genügend Goldmünzen!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (Dungeon.Goldmünzen >= 35)
- {
- Dungeon.Goldmünzen -= 35;
- Dungeon.Leben += 3;
- if (Dungeon.Leben > 6)
- {
- Dungeon.Leben = 6;
- }
- Dungeon.InfoSetzen();
- }
- else
- {
- MessageBox.Show("Du brauchst 35 Goldmünzen!", "Du hast nicht genügend Goldmünzen!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (Dungeon.Goldmünzen >= 45)
- {
- Dungeon.Goldmünzen -= 45;
- Dungeon.Leben += 6;
- if (Dungeon.Leben > 6)
- {
- Dungeon.Leben = 6;
- }
- Dungeon.InfoSetzen();
- }
- else
- {
- MessageBox.Show("Du brauchst 45 Goldmünzen!", "Du hast nicht genügend Goldmünzen!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
There are only 10 types of people in the world: Those who understand binary and those who don't.