Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
156 views
in Technique[技术] by (71.8m points)

c# - Form and designer files not linking in Solution Explorer

I can't seem to get the form and the designer files to link in my project. They look like this in the Solution Explorer.

enter image description here

I have excluded the files from the project and then tried including them back in the project, but this didn't work. Below is the designer code and a snippet of the forms code in case there is something in there.

public partial class FormPrompt
{
  private Button ButtonOk;
  private Container Components;
  private Label LabelPleaseEnter;
  private Label LabelPrompt;
  private TextBox TextBoxData;

  private void InitializeComponent()
  {
    this.LabelPleaseEnter = new Label();
    this.LabelPrompt = new Label();
    this.TextBoxData = new TextBox();
    this.ButtonOk = new Button();
    this.LabelPleaseEnter.Location = new Point(8, 0x58);
    this.LabelPleaseEnter.Size = new Size(0x48, 0x10);
    this.LabelPleaseEnter.Text = "Please enter";
    this.LabelPrompt.Location = new Point(80, 0x58);
    this.LabelPrompt.Size = new Size(0x98, 0x10);
    this.LabelPrompt.Text = "LabelPrompt";
    this.TextBoxData.Location = new Point(8, 0x80);
    this.TextBoxData.Size = new Size(0xe0, 20);
    this.TextBoxData.Text = "TextBoxData";
    this.TextBoxData.KeyDown += new KeyEventHandler(this.FormPrompt_KeyDown);
    this.ButtonOk.Location = new Point(8, 0x100);
    this.ButtonOk.Size = new Size(0xe0, 0x38);
    this.ButtonOk.Text = "Ok";
    this.ButtonOk.Click += new EventHandler(this.ButtonOk_Click);
    base.ClientSize = new Size(240, 0x13e);
    base.Controls.Add(this.TextBoxData);
    base.Controls.Add(this.ButtonOk);
    base.Controls.Add(this.LabelPrompt);
    base.Controls.Add(this.LabelPleaseEnter);
    this.Text = "WinForm";
    base.KeyDown += new KeyEventHandler(this.FormPrompt_KeyDown);
  }
}    


public partial class FormPrompt : Form
{

  internal DateTime FDateData;
  internal DateTimePicker FDatePicker;
  internal decimal FDecimalData;
  internal int FIntData;
  internal TPromptType FPromptType;
  internal string FStringData;


  public FormPrompt()
  {
    this.InitializeComponent();
    this.FDatePicker = new DateTimePicker();
    this.FDatePicker.Top = this.TextBoxData.Top;
    this.FDatePicker.Left = this.TextBoxData.Left;
    this.FDatePicker.Width = this.TextBoxData.Width;
    this.FDatePicker.Height = this.TextBoxData.Height;
    this.FDatePicker.Format = DateTimePickerFormat.Short;
    base.Controls.Add(this.FDatePicker);
  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've seen the same problem in Visual Studio 2008. Usually after compiling or closing and re-opening the solution the problem would fix itself. In Visual Studio 2012 I know that I have problems if I try to Add > Existing Item and choose all three files. Typically you only want to add the top level form.cs and VS will automatically include the .designer.cs and .resx files.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...