问题描述
- 关于动态创建MenuScrip,怎么把menuScrip写进一个。cs文件里
-
如果直接copy进一个.CS文件里,提示 this.Hide();、 this.SuspendLayout();、 this.Controls.Add(this.menuStrip1);、this.ResumeLayout(false);错误private void 工序录入ToolStripMenuItem_Click(object sender, EventArgs e) { 工序资料维护 frmGXLR = new 工序资料维护(); frmGXLR.Show(); this.Hide(); } private void 录入ToolStripMenuItem1_Click(object sender, EventArgs e) { 中小修管理录入 frmZXXGLLR = new 中小修管理录入(); frmZXXGLLR.Show(); this.Hide(); } //动态创建menuSctrip private void addMenuSctrip() { this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.文件ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.文件ToolStripMenuItem, this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(284, 25); this.menuStrip1.TabIndex = 40; this.menuStrip1.Text = "menuStrip1"; // // // 文件ToolStripMenuItem // this.文件ToolStripMenuItem.Name = "文件ToolStripMenuItem"; this.文件ToolStripMenuItem.Size = new System.Drawing.Size(44, 21); this.文件ToolStripMenuItem.Text = "文件"; this.Controls.Add(this.menuStrip1); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); } private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem 文件ToolStripMenuItem;
解决方案
我的这段代码是从一个form中直接拷出来的,这段代码在form中可以使用,但是在CS里面会报错,
解决方案二:
求助!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
时间: 2024-10-03 05:16:25