lundi 13 juin 2016

Unable to view my form in the form designer

I added a new class to my C# project. Very simple, and based on many examples I have found:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GENIO_Viewer
{
    class DBTableLayoutPanel : TableLayoutPanel
    {
        public DBTableLayoutPanel() : base()
        {
            DoubleBuffered = true;
        }
    }
}

I then edited the designer class file to use the revised object (code cut down):

private void InitializeComponent()
{
    this.tableLayoutPanel = new DBTableLayoutPanel();
    // tableLayoutPanel
    // 
    this.tableLayoutPanel.AutoSize = true;
    this.tableLayoutPanel.BackColor = System.Drawing.Color.Black;
    this.tableLayoutPanel.ColumnCount = 1;
    this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
    this.tableLayoutPanel.Cursor = System.Windows.Forms.Cursors.Cross;
    this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
    this.tableLayoutPanel.Location = new System.Drawing.Point(0, 24);
    this.tableLayoutPanel.Name = "tableLayoutPanel";
    this.tableLayoutPanel.RowCount = 1;
    this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
    this.tableLayoutPanel.Size = new System.Drawing.Size(555, 359);
    this.tableLayoutPanel.TabIndex = 4;
}

It compiles OK. But when I go to display teh form in the editor I get a problem:

Errors

Why is this? I can't work out what I have to do to fix it.

Update:

This is full form definition for the designer file. It only works if I comment out the DBTableLayoutPanel lines and replace with the commented out lines. Confused. :

using System;

namespace GENIO_Viewer
{
    partial class GENIO_Viewer_Form
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();

                m_moduleTD_Tb.Dispose();
                m_hostApp.Dispose();
                m_sysSrv.Dispose();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                Teigha.Core.Globals.odgsUninitialize();
                Teigha.Core.Globals.odrxUninitialize();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GENIO_Viewer_Form));
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.toolStripCoordinate = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripProgressBar = new System.Windows.Forms.ToolStripProgressBar();
            this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripCoordinates = new System.Windows.Forms.ToolStripStatusLabel();
            //this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
            this.tableLayoutPanel = new GENIO_Viewer.DBTableLayoutPanel();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.menuFile = new System.Windows.Forms.ToolStripMenuItem();
            this.menuFile_LoadGenio = new System.Windows.Forms.ToolStripMenuItem();
            this.menuFile_SaveAutoCAD = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.menuFile_RecentFile = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
            this.menuFile_Exit = new System.Windows.Forms.ToolStripMenuItem();
            this.menuView = new System.Windows.Forms.ToolStripMenuItem();
            this.menuViewCodeEditor = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
            this.menuView_ZoomExtents = new System.Windows.Forms.ToolStripMenuItem();
            this.menuView_ZoomWindow = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStrip = new System.Windows.Forms.ToolStrip();
            this.toolStripButton_ZoomWindow = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton_ZoomExtents = new System.Windows.Forms.ToolStripButton();
            this.statusStrip1.SuspendLayout();
            this.menuStrip1.SuspendLayout();
            this.toolStrip.SuspendLayout();
            this.SuspendLayout();
            // 
            // toolStripButton1
            // 
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(23, 23);
            // 
            // statusStrip1
            // 
            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripCoordinate,
            this.toolStripProgressBar,
            this.toolStripStatusLabel,
            this.toolStripCoordinates});
            this.statusStrip1.Location = new System.Drawing.Point(0, 383);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(555, 22);
            this.statusStrip1.TabIndex = 3;
            this.statusStrip1.Text = "statusStrip";
            // 
            // toolStripCoordinate
            // 
            this.toolStripCoordinate.AutoSize = false;
            this.toolStripCoordinate.Name = "toolStripCoordinate";
            this.toolStripCoordinate.Size = new System.Drawing.Size(200, 17);
            // 
            // toolStripProgressBar
            // 
            this.toolStripProgressBar.AutoSize = false;
            this.toolStripProgressBar.Name = "toolStripProgressBar";
            this.toolStripProgressBar.Size = new System.Drawing.Size(100, 16);
            // 
            // toolStripStatusLabel
            // 
            this.toolStripStatusLabel.AutoSize = false;
            this.toolStripStatusLabel.Name = "toolStripStatusLabel";
            this.toolStripStatusLabel.Size = new System.Drawing.Size(257, 17);
            this.toolStripStatusLabel.Spring = true;
            this.toolStripStatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // toolStripCoordinates
            // 
            this.toolStripCoordinates.Name = "toolStripCoordinates";
            this.toolStripCoordinates.Size = new System.Drawing.Size(0, 0);
            // 
            // tableLayoutPanel
            // 
            this.tableLayoutPanel.AutoSize = true;
            this.tableLayoutPanel.BackColor = System.Drawing.Color.LightGray;
            this.tableLayoutPanel.ColumnCount = 1;
            this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel.Cursor = System.Windows.Forms.Cursors.Cross;
            this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel.Location = new System.Drawing.Point(0, 24);
            this.tableLayoutPanel.Name = "tableLayoutPanel";
            this.tableLayoutPanel.RowCount = 1;
            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel.Size = new System.Drawing.Size(555, 359);
            this.tableLayoutPanel.TabIndex = 4;
            // 
            // menuStrip1
            // 
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.menuFile,
            this.menuView});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(555, 24);
            this.menuStrip1.TabIndex = 5;
            this.menuStrip1.Text = "menuStrip1";
            // 
            // menuFile
            // 
            this.menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.menuFile_LoadGenio,
            this.menuFile_SaveAutoCAD,
            this.toolStripSeparator1,
            this.menuFile_RecentFile,
            this.toolStripSeparator2,
            this.menuFile_Exit});
            this.menuFile.Name = "menuFile";
            this.menuFile.Size = new System.Drawing.Size(37, 20);
            this.menuFile.Text = "&File";
            this.menuFile.DropDownOpening += new System.EventHandler(this.menuFile_DropDownOpening);
            // 
            // menuFile_LoadGenio
            // 
            this.menuFile_LoadGenio.Name = "menuFile_LoadGenio";
            this.menuFile_LoadGenio.Size = new System.Drawing.Size(172, 22);
            this.menuFile_LoadGenio.Text = "Load GENIO File";
            this.menuFile_LoadGenio.Click += new System.EventHandler(this.menuFile_LoadGenio_Click);
            // 
            // menuFile_SaveAutoCAD
            // 
            this.menuFile_SaveAutoCAD.Name = "menuFile_SaveAutoCAD";
            this.menuFile_SaveAutoCAD.Size = new System.Drawing.Size(172, 22);
            this.menuFile_SaveAutoCAD.Text = "Save AutoCAD File";
            this.menuFile_SaveAutoCAD.Click += new System.EventHandler(this.menuFile_SaveAutoCAD_Click);
            // 
            // toolStripSeparator1
            // 
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(169, 6);
            // 
            // menuFile_RecentFile
            // 
            this.menuFile_RecentFile.Name = "menuFile_RecentFile";
            this.menuFile_RecentFile.Size = new System.Drawing.Size(172, 22);
            this.menuFile_RecentFile.Text = "Recent File";
            // 
            // toolStripSeparator2
            // 
            this.toolStripSeparator2.Name = "toolStripSeparator2";
            this.toolStripSeparator2.Size = new System.Drawing.Size(169, 6);
            // 
            // menuFile_Exit
            // 
            this.menuFile_Exit.Name = "menuFile_Exit";
            this.menuFile_Exit.Size = new System.Drawing.Size(172, 22);
            this.menuFile_Exit.Text = "E&xit";
            this.menuFile_Exit.Click += new System.EventHandler(this.menuFile_Exit_Click);
            // 
            // menuView
            // 
            this.menuView.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.menuViewCodeEditor,
            this.toolStripSeparator3,
            this.menuView_ZoomExtents,
            this.menuView_ZoomWindow});
            this.menuView.Name = "menuView";
            this.menuView.Size = new System.Drawing.Size(44, 20);
            this.menuView.Text = "&View";
            this.menuView.DropDownOpening += new System.EventHandler(this.menuView_DropDownOpening);
            // 
            // menuViewCodeEditor
            // 
            this.menuViewCodeEditor.Name = "menuViewCodeEditor";
            this.menuViewCodeEditor.Size = new System.Drawing.Size(153, 22);
            this.menuViewCodeEditor.Text = "Code Editor";
            this.menuViewCodeEditor.Click += new System.EventHandler(this.menuViewCodeEditor_Click);
            // 
            // toolStripSeparator3
            // 
            this.toolStripSeparator3.Name = "toolStripSeparator3";
            this.toolStripSeparator3.Size = new System.Drawing.Size(150, 6);
            // 
            // menuView_ZoomExtents
            // 
            this.menuView_ZoomExtents.Name = "menuView_ZoomExtents";
            this.menuView_ZoomExtents.Size = new System.Drawing.Size(153, 22);
            this.menuView_ZoomExtents.Text = "Zoom &Extents";
            this.menuView_ZoomExtents.Click += new System.EventHandler(this.menuView_ZoomExtents_Click);
            // 
            // menuView_ZoomWindow
            // 
            this.menuView_ZoomWindow.Name = "menuView_ZoomWindow";
            this.menuView_ZoomWindow.Size = new System.Drawing.Size(153, 22);
            this.menuView_ZoomWindow.Text = "Zoom &Window";
            this.menuView_ZoomWindow.Click += new System.EventHandler(this.menuView_ZoomWindow_Click);
            // 
            // toolStrip
            // 
            this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton_ZoomWindow,
            this.toolStripButton_ZoomExtents});
            this.toolStrip.Location = new System.Drawing.Point(0, 24);
            this.toolStrip.Name = "toolStrip";
            this.toolStrip.Size = new System.Drawing.Size(555, 25);
            this.toolStrip.TabIndex = 6;
            this.toolStrip.Text = "toolStrip";
            // 
            // toolStripButton_ZoomWindow
            // 
            this.toolStripButton_ZoomWindow.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton_ZoomWindow.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton_ZoomWindow.Image")));
            this.toolStripButton_ZoomWindow.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton_ZoomWindow.Name = "toolStripButton_ZoomWindow";
            this.toolStripButton_ZoomWindow.Size = new System.Drawing.Size(23, 22);
            this.toolStripButton_ZoomWindow.Text = "Zoom Window";
            this.toolStripButton_ZoomWindow.Click += new System.EventHandler(this.toolStripButton_ZoomWindow_Click);
            // 
            // toolStripButton_ZoomExtents
            // 
            this.toolStripButton_ZoomExtents.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton_ZoomExtents.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton_ZoomExtents.Image")));
            this.toolStripButton_ZoomExtents.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton_ZoomExtents.Name = "toolStripButton_ZoomExtents";
            this.toolStripButton_ZoomExtents.Size = new System.Drawing.Size(23, 22);
            this.toolStripButton_ZoomExtents.Text = "Zoom Extents";
            this.toolStripButton_ZoomExtents.Click += new System.EventHandler(this.toolStripButton_ZoomExtents_Click);
            // 
            // GENIO_Viewer_Form
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(555, 405);
            this.Controls.Add(this.toolStrip);
            this.Controls.Add(this.tableLayoutPanel);
            this.Controls.Add(this.statusStrip1);
            this.Controls.Add(this.menuStrip1);
            this.Cursor = System.Windows.Forms.Cursors.Default;
            this.DoubleBuffered = true;
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "GENIO_Viewer_Form";
            this.Text = "GENIO Viewer";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GENIO_Viewer_Form_FormClosing);
            this.Load += new System.EventHandler(this.GENIO_Viewer_Form_Load);
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.toolStrip.ResumeLayout(false);
            this.toolStrip.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.ToolStripButton toolStripButton1;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel;
        private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar;
        //private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
        private GENIO_Viewer.DBTableLayoutPanel tableLayoutPanel;
        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem menuFile;
        private System.Windows.Forms.ToolStripMenuItem menuView;
        private System.Windows.Forms.ToolStripMenuItem menuView_ZoomExtents;
        private System.Windows.Forms.ToolStripMenuItem menuView_ZoomWindow;
        private System.Windows.Forms.ToolStripMenuItem menuFile_LoadGenio;
        private System.Windows.Forms.ToolStripMenuItem menuFile_SaveAutoCAD;
        private System.Windows.Forms.ToolStrip toolStrip;
        private System.Windows.Forms.ToolStripButton toolStripButton_ZoomWindow;
        private System.Windows.Forms.ToolStripButton toolStripButton_ZoomExtents;
        private System.Windows.Forms.ToolStripStatusLabel toolStripCoordinates;
        private System.Windows.Forms.ToolStripStatusLabel toolStripCoordinate;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
        private System.Windows.Forms.ToolStripMenuItem menuFile_RecentFile;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
        private System.Windows.Forms.ToolStripMenuItem menuFile_Exit;
        private System.Windows.Forms.ToolStripMenuItem menuViewCodeEditor;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
    }
}

Update: This also happens when I inherit DataGridView and set DoubleBuffered. Renders editor inoperable. 😕

Aucun commentaire:

Enregistrer un commentaire