[.net] Windows Form Designer

Started by
6 comments, last by capn_midnight 15 years, 11 months ago
I'm currently wrestling with the windows for designer in attempts to create a gui. I have a UserControl class and Im adding controls to this. Lets say I add a check box, i name it, change the text, save, add a new check box, name it save, etc. I go through, for specificity's sake, 3 check boxes, 2 labels, a numericUpDown, a text box and a button. Looks fine, I save and build. Alas, the designer has created upwards of 4 controls for each control i have created. I have checkBoxFoo, the first one i created. When i view the code, i have been given 4 of these, all named the same. Aparently the windows forms designer has a bug, or a multitude of bugs. Swell. I delete these extra controls, fix the code that broke, go back to the designer, and there it is. "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))" //one of two errors i tend to get// I can no longer use the designer. Sure the code now compiles and the form works great, save for the delegates i was never able to add, the controls work fine. I have this problem trillions of times a day. My question(yes there is one ;P ) is how do i get around this? I have come to grips with the fact that windows forms designer is going to put it in my rectum daily. Great, i just bring a tube of KY to work with me. Has anone been able to work around this, though? Maybe some manner of working, or cluster of properties i could set to stop the designer from violating me? Cheers.
We have youth, how about a fountain of smart.e4 e5 f4 d5
Advertisement
I've never had too many issues with the forms designer. Are you using C# or C++/CLI? What's the generated designer code look like (paste it here)?
C++/CLI the code i have right now is:

#pragma onceusing namespace System;using namespace System::ComponentModel;using namespace System::Collections;using namespace System::Windows::Forms;using namespace System::Data;using namespace System::Drawing;namespace Odin {	/// <summary>	/// Summary for GraphicsOptions	/// </summary>	public ref class GraphicsOptions : public System::Windows::Forms::UserControl	{	public:		GraphicsOptions(void)		{			InitializeComponent();			//			//TODO: Add the constructor code here			//		}	protected:		/// <summary>		/// Clean up any resources being used.		/// </summary>		~GraphicsOptions()		{			if (components)			{				delete components;			}        }    private: System::Windows::Forms::CheckBox^  checkBoxShowGrid;    protected:     private: System::Windows::Forms::CheckBox^  checkBoxShapGrid;    private: System::Windows::Forms::CheckBox^  checkBoxOrigin;    private: System::Windows::Forms::Label^  label1;    private: System::Windows::Forms::NumericUpDown^  sliderGridSize;    private: System::Windows::Forms::TextBox^  textBox1;    private: System::Windows::Forms::Label^  label2;    private: System::Windows::Forms::Button^  buttonDefaultModel;    private: System::Windows::Forms::CheckBox^  checkBoxShowGrid;    protected:     private: System::Windows::Forms::CheckBox^  checkBoxShapGrid;    private: System::Windows::Forms::CheckBox^  checkBoxOrigin;    private: System::Windows::Forms::Label^  label1;    private: System::Windows::Forms::NumericUpDown^  sliderGridSize;    private: System::Windows::Forms::TextBox^  textBox1;    private: System::Windows::Forms::Label^  label2;    private: System::Windows::Forms::Button^  buttonDefaultModel;    private: System::Windows::Forms::CheckBox^  checkBoxShowGrid;    protected:     private: System::Windows::Forms::CheckBox^  checkBoxShapGrid;    private: System::Windows::Forms::CheckBox^  checkBoxShowGrid;    protected: 	private:		/// <summary>		/// Required designer variable.		/// </summary>		System::ComponentModel::Container ^components;#pragma 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>		void InitializeComponent(void)        {            this->checkBoxShowGrid = (gcnew System::Windows::Forms::CheckBox());            this->checkBoxShapGrid = (gcnew System::Windows::Forms::CheckBox());            this->SuspendLayout();            //             // checkBoxShowGrid            //             this->checkBoxShowGrid->AutoSize = true;            this->checkBoxShowGrid->Location = System::Drawing::Point(4, 4);            this->checkBoxShowGrid->Name = L"checkBoxShowGrid";            this->checkBoxShowGrid->Size = System::Drawing::Size(75, 17);            this->checkBoxShowGrid->TabIndex = 0;            this->checkBoxShowGrid->Text = L"Show Grid";            this->checkBoxShowGrid->UseVisualStyleBackColor = true;            //             // checkBoxShapGrid            //             this->checkBoxShapGrid->AutoSize = true;            this->checkBoxShapGrid->Location = System::Drawing::Point(4, 28);            this->checkBoxShapGrid->Name = L"checkBoxShapGrid";            this->checkBoxShapGrid->Size = System::Drawing::Size(85, 17);            this->checkBoxShapGrid->TabIndex = 1;            this->checkBoxShapGrid->Text = L"Snap to Grid";            this->checkBoxShapGrid->UseVisualStyleBackColor = true;            //             // GraphicsOptions            //             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;            this->Controls->Add(this->checkBoxShapGrid);            this->Controls->Add(this->checkBoxShowGrid);            this->Name = L"GraphicsOptions";            this->Size = System::Drawing::Size(434, 262);            this->ResumeLayout(false);            this->PerformLayout();        }#pragma endregion        private: System::Void GraphicsOptions::buttonBwsDefModel_OnClick(System::Object^  sender, System::EventArgs^  e);	};}


The designer has failed to properly create an of my controls in the initialize Component accept for the first two checkboxes, but my designer right now shows them as there. No error yet because i have yet to delete the duplicates. Partly out of shear terror, partly because it hasnt even created them properly yet.
We have youth, how about a fountain of smart.e4 e5 f4 d5
I've heard lots of horror stories about the designer-generated code for C++/CLI. Unfortunately I don't have any experience actually using the designer in C++/CLI; I stay in C# where the designer has far fewer errors which are far easier to fix. So I can't provide much in the way of insight as to why the designer broke things and how you might avoid it in the future, alas.

Ya, ive tried creating controls one at a time and saving then going back and forth from code to designer, but two checkboxes in the has already duplicated the first. There appears to be nothing i can do, but grit my teeth and take it.

If it duplicated and actually set the controls inside the InitializeComponent, it wouldnt be so bad, i could just remoe duplicates when im doen creating new controls and then deal with it, but i have to copy positions from the designer with all the other properties that are "default" and hand create the controls...

i here there is some known issues on the msdn forums, but it doesnt provide workarounds just...ya we know theres and issue, sorry...

*shrug*

im about to pull a doctor scratch and sniff and yank my hair out.
We have youth, how about a fountain of smart.e4 e5 f4 d5
Hey, sorry to bump this thread up again, but I had the same problem with my project. I deleted the project's intellisense database and it worked again, don't know for how long though, so give it a try.

good luck :)
thanks. the designer apparently has no issues on other computers that im aware of and the same on a few others. It may be that something became corrupt so ill try destroying the intermediate files and going from there. Cheers.
We have youth, how about a fountain of smart.e4 e5 f4 d5
You might want to also try running "<Visual Studio Install Directory>\Common7\IDE\devenv.exe /resetuserdata" from the command line. It will clear out any config settings that VS has stored. Sometimes they can get corrupted and really bork stuff. It's less effort than reinstalling VS.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

This topic is closed to new replies.

Advertisement