C# 更改文件名后获取错误消息
更改文件名后,我发现了几个错误。从默认表单名(Form2.cs),(Form1.cs)等到System.cs,LoginPage.cs,当我更改回默认表单名(Form2.cs)时,会发生这样的情况,出现错误。我该怎么办?是否有任何解决方案可以将此问题追溯到更改文件名之前的时间 这是“Form1.cs”的完整代码: “Form1.cs”上的错误是:C# 更改文件名后获取错误消息,c#,winforms,C#,Winforms,更改文件名后,我发现了几个错误。从默认表单名(Form2.cs),(Form1.cs)等到System.cs,LoginPage.cs,当我更改回默认表单名(Form2.cs)时,会发生这样的情况,出现错误。我该怎么办?是否有任何解决方案可以将此问题追溯到更改文件名之前的时间 这是“Form1.cs”的完整代码: “Form1.cs”上的错误是: “Sell\u System.Form1.cs”不包含“Drawing”的定义请查看设计器类(designer.cs),也许设计器类仍在引用旧文件名
“Sell\u System.Form1.cs”不包含“Drawing”的定义请查看设计器类(designer.cs),也许设计器类仍在引用旧文件名?显示完整代码。。并将错误粘贴为文本,而不是图像。您说您更改了文件名,但在屏幕截图中,错误指向FormN.Designer文件。您还需要匹配这些文件名,或者至少匹配其中包含的部分类的名称。@SonerGönül:请再次参考上面的问题。谢谢。@Rafal:是的,我已经更改了,但是当我更改名称时,出现了错误,所以我认为这是因为我更改了文件名,所以我再次将其重命名为默认文件名。但是,错误仍然出现
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.Globalization;
using System.Data.OleDb;
using System.Security.Principal;
namespace Sell_System
{
public partial class Form1 : Form
{
string connectionString = (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\Archives\Projects\Program\Sell System\Sell System\App_Data\db1.accdb;Persist Security Info=False;");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label4.Visible = false;
comboBox1.Items.Add("English");
comboBox1.Items.Add("Indonesian");
comboBox1.SelectedIndex = 0;
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT DISTINCT [Username] FROM [Member]", conn);
dReader = cmd.ExecuteReader();
AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
while (dReader.Read())
{
namesCollection.Add(dReader.GetString(0));
}
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
textBox1.AutoCompleteCustomSource = namesCollection;
dReader.Close();
conn.Close();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
DataTable dt = new DataTable();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Member] WHERE [Username]='" + textBox1.Text + "'AND [Password]='" + textBox2.Text + "'", conn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
if (dt.Rows.Count != 0)
{
this.Hide();
Form2 secondaryForm = new Form2(this);
secondaryForm.ShowDialog();
this.Close();
}
else if (textBox1.Text == "Admin" && textBox2.Text == "")
{
this.Hide();
Form5 fifthForm = new Form5();
fifthForm.ShowDialog();
this.Close();
}
else
{
label4.Visible = true;
if (comboBox1.SelectedItem.ToString() == "English")
{
RecursiveClearTextBoxes(this.Controls);
label4.Text = "Invalid Username or Password!";
label4.ForeColor = Form1.Drawing.Color.Red;
}
else if (comboBox1.SelectedItem.ToString() == "Indonesian")
{
RecursiveClearTextBoxes(this.Controls);
label4.Text = "Username atau Password anda salah!";
label4.ForeColor = Form1.Drawing.Color.Red;
}
}
conn.Close();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem.ToString() == "English")
{
ChangeLanguage("en");
}
else if (comboBox1.SelectedItem.ToString() == "Indonesian")
{
ChangeLanguage("id");
}
}
private void ChangeLanguage(string language)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, c.Name, new CultureInfo(language));
}
}
private void RecursiveClearTextBoxes(Control.ControlCollection cc)
{
foreach (Control ctrl in cc)
{
TextBox tb = ctrl as TextBox;
if (tb != null)
{
tb.Clear();
}
else
{
RecursiveClearTextBoxes(ctrl.Controls);
}
}
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.Hide();
Form3 thirdForm = new Form3();
thirdForm.ShowDialog();
this.Close();
}
protected virtual void ClosedHandler(object sender, EventArgs e)
{
FormsHandler.Remove(this);
}
}
}