Form and designer files not associated with Solution Explorer

I cannot get the form and designer files to link in my project. They look like in the solution explorer.

enter image description here

I excluded the files from the project, and then tried to include them back into the project, but that didn't work. Below is the developer code and a code snippet of the form, if there is something 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); } } 
+7
c # visual-studio-2008 visual-studio
source share
3 answers

I saw the same problem in Visual Studio 2008. Usually, after compiling or closing and reopening the solution, the problem will be fixed. In Visual Studio 2012, I know that I have problems if I try to add> An existing item and select all three files. Usually you want to add only the top level form.cs and VS automatically include the .designer.cs and .resx files.

+10
source share

Check the project file ( .csproj ).

Inside the ItemGroup node, see if the .designer file is .designer with the code file. The XML should look something like this:

 <Compile Include="FormPrompt.cs"> <SubType>Form</SubType> </Compile> <Compile Include="FormPrompt.Designer.cs"> <DependentUpon>FormPrompt.cs</DependentUpon> </Compile> 
+9
source share

In VS2017 (C #), to solve this, in my case:

  • exclude whole file
  • go to folder
  • rename the file (all 3 files .cs.Designer.cs.resx)
  • update solution
  • add to project back
0
source share

All Articles