C#VB2015导入的表单未在程序中引用

时间:2016-04-27 08:00:09

标签: c# forms winforms import

尝试将现有表单从一个项目添加到另一个项目时,我遇到了一些严重问题。我已经做了一些关于如何正确地将现有表单添加到项目的研究,我已经通过Add Existing找到了该文件。我还将原始项目重建为正确的.Net框架(因为它使用的是4.00而我当前的项目使用的是4.5.2)我遇到的问题是在我的主菜单中单击按钮时尝试启动新表单例如,在尝试引用表单(new Project.Test.Test)时,它不会显示它,它不会将表单识别为项目的一部分。

我发现的所有其他解决方案似乎都不适合我。

编辑:这是来自test.cs的代码

using System;
using System.Windows.Forms;
namespace StackedHeader
{
public partial class Test : Form
    {
        public Test()
        {
            InitializeComponent();

            StackedHeaderDecorator objREnderer = new StackedHeaderDecorator(dataGridView1);
            //dataGridView1.Columns[0].Visible = false;
            //dataGridView1.Columns[2].Visible = false;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 3; ++i)
            {
                int columnCount = dataGridView1.Columns.Count;
                dataGridView1.Columns.Add("Column" + dataGridView1.Columns.Count,
                                          "Parent[" + columnCount + "].Child 1.Child 2.Input Name");
                dataGridView1.Columns.Add("Column" + dataGridView1.Columns.Count ,
                                          "Parent[" + columnCount + "].Child 1.Child 2.Input Name 2");
                dataGridView1.Columns.Add("Column" + dataGridView1.Columns.Count,
                                          "Parent[" + columnCount + "].Child 1.Child 3.Input Name 3");
                dataGridView1.Columns.Add("Column" + dataGridView1.Columns.Count ,
                                          "Parent[" + columnCount + "].Child 1.Input Name 4");
                dataGridView1.Columns.Add("Column" + dataGridView1.Columns.Count ,
                                          "Parent[" + columnCount + "].Input Name 5");
            }
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}

这是我的表单设计代码:

namespace StackedHeader
{
    partial class Test
    {
        /// <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();
            }
            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()
        {
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.e = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column17 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column18 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column19 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column20 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column21 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column22 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column23 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column24 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column25 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column26 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column27 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column28 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.listBox1 = new System.Windows.Forms.ListBox();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // dataGridView1
            // 
            this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.e,
            this.Column3,
            this.Column4,
            this.Column5,
            this.Column2,
            this.Column6,
            this.Column7,
            this.Column8,
            this.Column9,
            this.Column10,
            this.Column11,
            this.Column12,
            this.Column13,
            this.Column14,
            this.Column15,
            this.Column16,
            this.Column17,
            this.Column18,
            this.Column19,
            this.Column20,
            this.Column21,
            this.Column22,
            this.Column23,
            this.Column24,
            this.Column25,
            this.Column26,
            this.Column27,
            this.Column28});
            this.dataGridView1.Location = new System.Drawing.Point(12, 12);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.Size = new System.Drawing.Size(1492, 697);
            this.dataGridView1.TabIndex = 0;
            this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
            // 
            // Column1
            // 
            this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
            this.Column1.HeaderText = "MasterRoster.Monday.On";
            this.Column1.Name = "Column1";
            this.Column1.Width = 50;
            // 
            // e
            // 
            this.e.HeaderText = "MasterRoster.Monday.Off";
            this.e.Name = "e";
            this.e.Width = 50;
            // 
            // Column3
            // 
            this.Column3.HeaderText = "MasterRoster.Monday.Duty";
            this.Column3.Name = "Column3";
            this.Column3.Width = 50;
            // 
            // Column4
            // 
            this.Column4.HeaderText = "MasterRoster.Monday.Hours";
            this.Column4.Name = "Column4";
            this.Column4.Width = 50;
            // 
            // Column5
            // 
            this.Column5.HeaderText = "MasterRoster.Tuesday.On";
            this.Column5.Name = "Column5";
            this.Column5.Width = 50;
            // 
            // Column2
            // 
            this.Column2.HeaderText = "MasterRoster.Tuesday.Off";
            this.Column2.Name = "Column2";
            this.Column2.Width = 50;
            // 
            // Column6
            // 
            this.Column6.HeaderText = "MasterRoster.Tuesday.Duty";
            this.Column6.Name = "Column6";
            this.Column6.Width = 50;
            // 
            // Column7
            // 
            this.Column7.HeaderText = "MasterRoster.Tuesday.Hours";
            this.Column7.Name = "Column7";
            this.Column7.Width = 50;
            // 
            // Column8
            // 
            this.Column8.HeaderText = "MasterRoster.Wednesday.On";
            this.Column8.Name = "Column8";
            this.Column8.Width = 50;
            // 
            // Column9
            // 
            this.Column9.HeaderText = "MasterRoster.Wednesday.Off";
            this.Column9.Name = "Column9";
            this.Column9.Width = 50;
            // 
            // Column10
            // 
            this.Column10.HeaderText = "MasterRoster.Wednesday.Duty";
            this.Column10.Name = "Column10";
            this.Column10.Width = 50;
            // 
            // Column11
            // 
            this.Column11.HeaderText = "MasterRoster.Wednesday.Hours";
            this.Column11.Name = "Column11";
            this.Column11.Width = 50;
            // 
            // Column12
            // 
            this.Column12.HeaderText = "MasterRoster.Thursday.On";
            this.Column12.Name = "Column12";
            this.Column12.Width = 50;
            // 
            // Column13
            // 
            this.Column13.HeaderText = "MasterRoster.Thursday.Off";
            this.Column13.Name = "Column13";
            this.Column13.Width = 50;
            // 
            // Column14
            // 
            this.Column14.HeaderText = "MasterRoster.Thursday.Duty";
            this.Column14.Name = "Column14";
            this.Column14.Width = 50;
            // 
            // Column15
            // 
            this.Column15.HeaderText = "MasterRoster.Thursday.Hours";
            this.Column15.Name = "Column15";
            this.Column15.Width = 50;
            // 
            // Column16
            // 
            this.Column16.HeaderText = "MasterRoster.Friday.On";
            this.Column16.Name = "Column16";
            this.Column16.Width = 50;
            // 
            // Column17
            // 
            this.Column17.HeaderText = "MasterRoster.Friday.Off";
            this.Column17.Name = "Column17";
            this.Column17.Width = 50;
            // 
            // Column18
            // 
            this.Column18.HeaderText = "MasterRoster.Friday.Duty";
            this.Column18.Name = "Column18";
            this.Column18.Width = 50;
            // 
            // Column19
            // 
            this.Column19.HeaderText = "MasterRoster.Friday.Hours";
            this.Column19.Name = "Column19";
            this.Column19.Width = 50;
            // 
            // Column20
            // 
            this.Column20.HeaderText = "MasterRoster.Saturday.On";
            this.Column20.Name = "Column20";
            this.Column20.Width = 50;
            // 
            // Column21
            // 
            this.Column21.HeaderText = "MasterRoster.Saturday.Off";
            this.Column21.Name = "Column21";
            this.Column21.Width = 50;
            // 
            // Column22
            // 
            this.Column22.HeaderText = "MasterRoster.Saturday.Duty";
            this.Column22.Name = "Column22";
            this.Column22.Width = 50;
            // 
            // Column23
            // 
            this.Column23.HeaderText = "MasterRoster.Saturday.Hours";
            this.Column23.Name = "Column23";
            this.Column23.Width = 50;
            // 
            // Column24
            // 
            this.Column24.HeaderText = "MasterRoster.Sunday.On";
            this.Column24.Name = "Column24";
            this.Column24.Width = 50;
            // 
            // Column25
            // 
            this.Column25.HeaderText = "MasterRoster.Sunday.Off";
            this.Column25.Name = "Column25";
            this.Column25.Width = 50;
            // 
            // Column26
            // 
            this.Column26.HeaderText = "MasterRoster.Sunday.Duty";
            this.Column26.Name = "Column26";
            this.Column26.Width = 50;
            // 
            // Column27
            // 
            this.Column27.HeaderText = "MasterRoster.Sunday.Hours";
            this.Column27.Name = "Column27";
            this.Column27.Width = 50;
            // 
            // Column28
            // 
            this.Column28.HeaderText = "MasterRoster.Total Hours";
            this.Column28.Name = "Column28";
            this.Column28.Width = 50;
            // 
            // listBox1
            // 
            this.listBox1.FormattingEnabled = true;
            this.listBox1.Location = new System.Drawing.Point(1510, 46);
            this.listBox1.Name = "listBox1";
            this.listBox1.Size = new System.Drawing.Size(158, 680);
            this.listBox1.TabIndex = 1;
            // 
            // comboBox1
            // 
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Items.AddRange(new object[] {
            "All",
            "Monday",
            "Tuesday",
            "Wednesday",
            "Thursday",
            "Friday",
            "Saturday",
            "Sunday"});
            this.comboBox1.Location = new System.Drawing.Point(1510, 19);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(158, 21);
            this.comboBox1.TabIndex = 2;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(1510, 3);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(84, 13);
            this.label1.TabIndex = 3;
            this.label1.Text = "Duty Day Picker";
            // 
            // Test
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1670, 738);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.comboBox1);
            this.Controls.Add(this.listBox1);
            this.Controls.Add(this.dataGridView1);
            this.Name = "Test";
            this.Text = "Form1";
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.DataGridView dataGridView1;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
        private System.Windows.Forms.DataGridViewTextBoxColumn e;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column8;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column9;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column10;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column11;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column12;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column13;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column14;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column15;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column16;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column17;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column18;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column19;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column20;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column21;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column22;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column23;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column24;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column25;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column26;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column27;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column28;
        private System.Windows.Forms.ListBox listBox1;
        private System.Windows.Forms.ComboBox comboBox1;
        private System.Windows.Forms.Label label1;
    }
}

0 个答案:

没有答案