错误 CS0246: 找不到类型或命名空间名称“Form2”(是否缺少 using 指令或程序集引用?)

qq403017227 2008-11-04 12:48:17
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
/*
* 算法简述(主要分为如下三个步骤):
*
* 1、首先将该按钮上面的按钮推上去(相当于点击被“推上去”的这个按钮),在推动的过程中,
* 如果被推动的按钮的上面还有另一个按钮,则重复这个过程(步骤 1)
* 2、然后将自己推上去
* 3、最后将该按钮下面的按钮推下去(相当于点击被“推下去”的这个按钮),在推动的过程中,
* 如果被推动的按钮的上面还有另一个按钮,则重复这个过程(步骤 3)
*
* 整个过程就像你站在队伍中,你想前进,首先你得告诉站在你前面的人前进,然后你必须等待,直到你前面的人
* 前进之后你才能够前进。(你前面的人同样必须和你做同样的事,这个过程直到传达到第一个人为止)
*
*
*
* 还没有明白吗?没关系,我们来举例说明这个算法:
* 为了方便理解程序,我们以“按钮1”、“按钮2”、“按钮3”和“按钮4”这四个从上到下依次排列的按钮为例,
* 我们假设“按钮3”被点击:
* 1、将“按钮1”推到最顶端
* 2、将“按钮2”推到“按钮1”的下方。
* 3、将自己(“按钮3”)推上去;
* 4、将“按钮4”推下去。
*
*
* 本程序中主要运用了属性的特点。
* 因为使用的是中文编程,所以就不再详细说明了。
*/
namespace QQ3000
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
int a = 88;
int b = 66;


private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button 按钮_我的好友;
private System.Windows.Forms.Button 按钮_陌生人;
private System.Windows.Forms.Button 按钮_黑名单;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.Button button1;

private int 陌生人
{
get
{
return 按钮_陌生人.Top;
}
set
{
if (value < 按钮_陌生人.Top)
{
按钮_陌生人.Top = 按钮_我的好友.Top + 按钮_我的好友.Height;
}
else
{
黑名单++;
按钮_陌生人.Top = 按钮_黑名单.Top - 按钮_陌生人.Height;
}
}
}
private int 黑名单
{
get
{
return 按钮_黑名单.Top;
}
set
{
if (value < 按钮_黑名单.Top)
{
陌生人--;
按钮_黑名单.Top = 按钮_陌生人.Bottom + 1;
}
else
{
按钮_黑名单.Top = groupBox1.Height - 按钮_陌生人.Height - 20;
}
}
}
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

...全文
4207 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xueminfeng 2011-08-02
  • 打赏
  • 举报
回复
那位大牛,帮忙解答一下么
xueminfeng 2011-08-02
  • 打赏
  • 举报
回复
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.Drawing.Drawing2D;

namespace 算法实现_图
{
public partial class Form1 : Form
{
const int n = 20;
TextBox[] textBox = new TextBox[n];
TextBox[,] textBox_1 = new TextBox[n, n];
Label label;
int i, j;
bool mark = true;
string[] s = new string[n];

public Form1()
{
InitializeComponent();
}


private void set_textBox(TextBox textBox, int p, int q)
{
textBox = new TextBox();
textBox.Name = "textBox";
textBox.Visible = true;
textBox.Width = 21;
textBox.Height = 26;
textBox.Text = "";
this.Controls.Add(textBox);
textBox.Location = new Point(p, q);
textBox.Font = new Font("Arial", 12);
}

private void set_grouptextBox(TextBox textBox1, TextBox textBox2, TextBox textBox3, int p, int q)
{
set_textBox(textBox1, p, q);
set_textBox(textBox2, p + 24, q);
set_textBox(textBox3, p + 48, q);
}

private void set_label()
{
label = new Label();
label.Name = "label";
label.Text = "";
label.Visible = true;
label.AutoSize = true;
label.Font = new Font("幼圆", 12);
this.Controls.Add(label);
label.Location = new Point(1, 20);
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{

if (radioButton1.Checked)
{
radioButton1.Visible = radioButton2.Visible = label1.Visible = false;
label2.Text = "您要建立的有向图的顶点数和边数分别为:";
label2.Font = new Font("微软雅黑", 12);
label2.Visible = textBox1.Visible = textBox2.Visible = button1.Visible = true;
}
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
radioButton1.Visible = radioButton2.Visible = label1.Visible = false;
label2.Text = "您要建立的无向图的定点数和边数分别为:";
label2.Font = new Font("微软雅黑", 12);
label2.Visible = textBox1.Visible = textBox2.Visible = button1.Visible = true;
}
}

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
if (textBox1.Text == "" && textBox2.Text == "")
MessageBox.Show(this, "请输入顶点数和边数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (textBox1.Text == "" && textBox2.Text != "")
MessageBox.Show(this, "请输入顶点数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (textBox1.Text != "" && textBox2.Text == "")
MessageBox.Show(this, "请输入边数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

else
{
button2.Visible = true;
if (radioButton1.Checked)
{
label2.Visible = textBox1.Visible = textBox2.Visible = button1.Visible = false;
set_label();
label.Text = "请输入您要建立的有向图的各个顶点的数据域值:";
for (i = 0; i < Convert.ToSingle(textBox1.Text); i++)
{
set_textBox(textBox[i], 150 + 30 * i, 50);
}
}

if (radioButton2.Checked)
{
label2.Visible = textBox1.Visible = textBox2.Visible = button1.Visible = false;
set_label();
label.Text = "请输入您要建立的无向图的各个顶点的数据域值:";
for (i = 0; i < Convert.ToSingle(textBox1.Text); i++)
{
set_textBox(textBox[i], 150 + 30 * i, 50);
}
}
}
}

private void get_text(string[] s1)
{
for (i = 0; i < Convert.ToSingle(textBox1.Text); i++)
{
TextBox text = new TextBox();
text = textBox[i];
s1[i] = Convert.ToString(text.Text);
}
}

private void button2_Click(object sender, EventArgs e)
{
get_text(s);
for (i = 0; i < Convert.ToSingle(textBox1.Text); i++)
{
if (s[i] == "")
{
mark = false;
break;
}
}

while (mark == false)
{
get_text(s);
for (i = 0; i < Convert.ToSingle(textBox1.Text); i++)
{
if (s[i] == "")
{
MessageBox.Show(this, "还有未输入的顶点域值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
break;
}
else
mark = true;
}
}

set_label();
label.Text = "请输入您要建立的图的各个边\\(v1,v2,w):";
label.Location = new Point(1, 150);
for (i = 0; i < Convert.ToSingle(textBox2.Text); i++)
{
set_grouptextBox(textBox_1[i, 0], textBox_1[i, 1], textBox_1[i, 2], 230, 180 + 30 * i);
}
button3.Visible = true;
button3.Location = new Point(235, 180 + 30 * Convert.ToInt16(textBox2.Text));
}
}
}


错误 1 未能找到类型或命名空间名称“Form1”(是否缺少 using 指令或程序集引用?) F:\课程设计作业\数据结构\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs 18
xueminfeng 2011-08-02
  • 打赏
  • 举报
回复
我的Form1还有,可也出现了这样的问题
guo522801398 2010-12-31
  • 打赏
  • 举报
回复
同样的问题,求下解
gaara777 2010-09-27
  • 打赏
  • 举报
回复
学习中。。。。
贫僧又回来了 2008-11-04
  • 打赏
  • 举报
回复
好象根本就没FORM2的啊
qq403017227 2008-11-04
  • 打赏
  • 举报
回复
------ 已启动全部重新生成: 项目: test001, 配置: Debug Any CPU ------
C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\test001.exe /resource:obj\Debug\test001.Properties.Resources.resources /target:winexe Form1.cs Form1.Designer.cs Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs
C:\Users\SONGS\Documents\Visual Studio 2008\Projects\test001\test001\Program.cs(291,13): 错误 CS0246: 找不到类型或命名空间名称“Form2”(是否缺少 using 指令或程序集引用?)
C:\Users\SONGS\Documents\Visual Studio 2008\Projects\test001\test001\Program.cs(291,28): 错误 CS0246: 找不到类型或命名空间名称“Form2”(是否缺少 using 指令或程序集引用?)

编译完成 -- 2 个错误,0 个警告
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========

qq403017227 2008-11-04
  • 打赏
  • 举报
回复
this.按钮_陌生人.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.按钮_陌生人.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.按钮_陌生人.Location = new System.Drawing.Point(0, 28);
this.按钮_陌生人.Name = "按钮_陌生人";
this.按钮_陌生人.Size = new System.Drawing.Size(97, 28);
this.按钮_陌生人.TabIndex = 1;
this.按钮_陌生人.Text = "陌 生 人";
this.按钮_陌生人.Click += new System.EventHandler(this.按钮_陌生人_单击);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.groupBox1.Controls.Add(this.按钮_黑名单);
this.groupBox1.Controls.Add(this.按钮_陌生人);
this.groupBox1.Controls.Add(this.按钮_我的好友);
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.groupBox1.Location = new System.Drawing.Point(0, 22);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(97, 360);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// 按钮_我的好友
//
this.按钮_我的好友.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.按钮_我的好友.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.按钮_我的好友.Location = new System.Drawing.Point(0, 1);
this.按钮_我的好友.Name = "按钮_我的好友";
this.按钮_我的好友.Size = new System.Drawing.Size(97, 28);
this.按钮_我的好友.TabIndex = 0;
this.按钮_我的好友.Text = "我 的 好 友";
this.按钮_我的好友.Click += new System.EventHandler(this.按钮_我的好友_单击);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(11, 2);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(28, 19);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(39, 2);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(20, 21);
this.pictureBox2.TabIndex = 2;
this.pictureBox2.TabStop = false;
//
// pictureBox3
//
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
this.pictureBox3.Location = new System.Drawing.Point(70, 2);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(25, 19);
this.pictureBox3.TabIndex = 3;
this.pictureBox3.TabStop = false;
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.Info;
this.button1.Location = new System.Drawing.Point(4, 384);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 25);
this.button1.TabIndex = 4;
this.button1.Text = "显示对话窗口";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.ClientSize = new System.Drawing.Size(97, 408);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox3);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "QQ2008";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void 按钮_我的好友_单击(object sender, System.EventArgs e)
{
陌生人++;
}

private void 按钮_陌生人_单击(object sender, System.EventArgs e)
{
陌生人--;
黑名单++;
}

private void 按钮_黑名单_单击(object sender, System.EventArgs e)
{
陌生人--;
黑名单--;
}

private void groupBox1_Enter(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
Form2 dg = new Form2();
dg.Show();
}

private void Form1_Load(object sender, System.EventArgs e)
{

}
}
}

qq403017227 2008-11-04
  • 打赏
  • 举报
回复
public Form1()
{
//
// Required for Windows Form Designer support
//
int[,] ax = new int[2, 2] { { 1, 2 }, { 3, 4 } };
InitializeComponent();
int[,] ax1 = new int[2, 2] { { 1, 2 }, { 3, 4 } };
//
// TODO: Add any constructor code after InitializeComponent call
//
System.Collections.Hashtable abc = new Hashtable();
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.按钮_黑名单 = new System.Windows.Forms.Button();
this.按钮_陌生人 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.按钮_我的好友 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// 按钮_黑名单
//
this.按钮_黑名单.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.按钮_黑名单.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.按钮_黑名单.Location = new System.Drawing.Point(0, 56);
this.按钮_黑名单.Name = "按钮_黑名单";
this.按钮_黑名单.Size = new System.Drawing.Size(97, 27);
this.按钮_黑名单.TabIndex = 2;
this.按钮_黑名单.Text = "黑 名 单";
this.按钮_黑名单.Click += new System.EventHandler(this.按钮_黑名单_单击);
//
// 按钮_陌生人
//
acqy 2008-11-04
  • 打赏
  • 举报
回复
检查你的项目里面、或者你项目所引用的你自己开发的Class Library里面有没有Form2?
gdyaojie 2008-11-04
  • 打赏
  • 举报
回复
是不是你把FORM2删除了, 但是没有删除PROGRAM.CS的关于FORM2的代码?(自动生成的关于FORM2的代码)
内容概要:本文系统研究了开关频率大于谐振频率(fs>fr)工况下,移相混合控制LLC谐振变换器在低压增益区域的工作特性,深入分析其在变频与移相结合控制模式下的调制机理、工作模态划分及损耗分布规律。通过Simulink平台构建高保真仿真模型,对变换器在不同负载和输入条件下的电压增益、转换效率、关键器件电压电流应力等性能指标进行了全面仿真验证,重点探讨了其在低增益区间的软开关实现能力与效率优化潜力,旨在提升LLC变换器在宽范围输入输出应用中的动态响应与能源转换效率。; 适合人群:从事电力电子变换器设计、高频电源开发及相关领域的高校研究生、科研院所研究人员及企业研发工程师,要求具备扎实的电路理论基础、电力电子技术知识以及一定的Simulink仿真能力。; 使用场景及目标:①深入理解LLC谐振变换器在fs>fr条件下采用移相混合控制的内在工作机理与模态转换过程;②掌握利用Simulink搭建复杂谐振变换器精确仿真模型的方法与技巧;③分析并优化低压增益区的增益特性与损耗构成,为设计高效率、高功率密度的软开关电源提供理论依据和数据支持; 阅读建议:建议读者结合文中所述仿真模型,亲自复现仿真过程,重点观察不同控制参数(如移相比、开关频率)对电压增益曲线和关键波形的影响,并对比传统变频控制策略,深入探究混合控制在拓宽调压范围、提升轻载效率方面的优势,从而深化对现代高效谐振电源设计的理解。
内容概要:本文提出了一种基于粒子群优化算法(PSO)的配电网光伏储能双层优化配置模型,以IEEE33节点系统为标准算例,实现光伏发电单元与储能系统的协同选址与定容优化。该模型采用双层架构设计,上层以投资成本、运行经济性及网络损耗最小为目标优化设备配置方案,下层通过潮流计算评估系统在不同负荷场景下的运行性能,综合考虑电压稳定性、供电可靠性及可再生能源消纳能力,最终通过Matlab编程实现完整求解流程,为高渗透率分布式电源接入背景下的配电网规划提供了有效的技术支撑。; 适合人群:具备电力系统分析基础和Matlab编程能力的研究生、高校科研人员及从事新能源并网、智能配电网规划与优化的工程技术人员。; 使用场景及目标:①研究含高比例光伏接入的配电网规划与运行协同优化问题;②掌握双层优化建模方法与粒子群算法在复杂电力系统问题中的应用技巧;③为实际工程中分布式光伏与储能系统的科学选址与容量配置提供理论依据与仿真验证平台。; 阅读建议:建议读者结合Matlab代码深入理解双层迭代求解机制,重点关注算法收敛性分析、参数敏感性测试,并可通过更换初始种群、调整权重因子或引入其他标准测试系统(如IEEE69节点)进行对比实验,进一步验证所提模型的普适性与鲁棒性。
内容概要:本文围绕双机并联虚拟同步发电机(VSG)在微电网中的功率分配、黑启动、虚拟阻抗与预同步控制展开,基于Simulink平台构建了完整的微电网系统仿真模型。重点研究了VSG在双机并联运行下的有功/无功功率均分控制策略,通过引入虚拟阻抗技术有效解决了因线路阻感比差异导致的功率分配不均问题。同时,设计了微电网黑启动流程与并网预同步控制模块,实现了待并网系统与主网在电压幅值、频率和相位上的精确同步,显著降低了并网冲击电流。系统整合了VSG控制、下垂控制、虚拟阻抗、锁相环(PLL)及预同步逻辑等关键环节,全面验证了多VSG协同运行的稳定性、自主恢复能力与并网可靠性。; 适合人群:具备电力系统、电力电子及自动控制等相关专业知识,从事微电网、分布式发电、VSG控制与并网技术研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①深入理解双机并联VSG系统中功率分配不均的机理及虚拟阻抗的补偿作用;②掌握微电网黑启动全过程及预同步控制的关键技术要点;③学习并实践基于Simulink的微电网多层次、多目标控制策略的建模与仿真方法;④为相关科研课题、毕业设计或实际工程项目提供可复现、可拓展的技术方案与仿真参考。; 阅读建议:建议结合提供的Simulink模型文件进行同步学习,重点关注VSG控制参数整定、虚拟阻抗设计原则、预同步切换逻辑等核心模块的实现细节,并可通过改变负载投切、线路参数或初始频率偏差等条件进行多工况仿真测试,以深入探究系统的动态响应特性与鲁棒性。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧