Autor Beitrag
xcoder44
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 29.12.08 17:45 
... hallo liebe coder, ich bin verzweifelt.

es kann doch nicht sein, dass ich bei VS2008 mit dem designer einen button auf meine Form ziehe und dieser nach dem kompilieren nicht angezeigt wird. Eigentlich wollte ich ein contextmenu erstellen, bis ich schließlich gemerkt habe, dass kein tool, control oder was auch immer angezeigt wird, was ich auf die form ziehe...

es ist doch alles gesetzt,
auch mit .Show() und .Visible=true habe ich schon gearbeitet, lächerlich...
hiiiilfe...

wo ist der fehler?
ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
namespace WindowsFormsApplication1
{
    partial class Form1
    {
        /// <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.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(9697);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(7523);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(292273);
            this.Controls.Add(this.button1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button button1;




    }
}


Moderiert von user profile iconNarses: Titel geändert.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 29.12.08 17:53 
Hallo, :welcome: im Forum!

Der Code sieht prinzipiell identisch aus zu dem eines neuen (und funktionierenden) Projekts bei mir. Was passiert denn in Form1_Load, das ja als Handler für das Laden des Formulars eingetragen ist?

Hast du das mal rausgenommen? (in Zeile 51 sieht man das)
xcoder44 Threadstarter
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 29.12.08 18:55 
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Visible = true;
            button1.Show();
        }

da passiert nicht viel, auch wenn ich die ziele 51 auskommentiere...

hier der restliche Code:

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;
using System.IO;

Form1.cs
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Visible = true;
            button1.Show();
        }
        private void öffnenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stream myStream;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\" ;
            openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
            openFileDialog1.FilterIndex = 2 ;
            openFileDialog1.RestoreDirectory = true ;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = openFileDialog1.OpenFile()) != null)
                {
                    // Insert code to read the stream here.
                    myStream.Close();
                }
            }
        }
    }
}


Program.cs
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    static class Program
    {
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 29.12.08 19:07 
Da fehlt in Form1.cs der Konstruktor (nach Zeile 4 müsste der hin z.B.), in dem der Aufruf von InitializeComponent steckt, hast du den weggelassen oder fehlt der wirklich? ;-)
ausblenden C#-Quelltext
1:
2:
3:
4:
        public Form1()
        {
            InitializeComponent();
        }
Wenn der fehlt werden die Komponenten natürlich gar nicht erzeugt.
xcoder44 Threadstarter
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 29.12.08 19:41 
... machmal ist verrückt ^^

vielen lieben dank, genau das wars... !

gruss,
Dieter