Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Okay so i have this variable
private System.Windows.Forms.DataGridView dgdisplay;


then when i add
this.Controls.Add(this.dgdisplay);

in the InitializeComponent() function it works just fine.

But when i change dgdisplay to:
private System.Windows.Forms.DataGridView [] dgdisplayX = new System.Windows.Forms.DataGridView [3];


and add this line in InitializeComponent():
dgdisplayX[0]=new System.Windows.Forms.DataGridView();


and change all the previous dgdisplay to dgdisplayX[0]

And change the Controls.Add() to:
this.Controls.Add(this.dgdisplayX[0]);


I get this error when switching to design mode:

Failed to load designer. Check the source code for syntax errors and check if all references are available.

ICSharpCode.FormsDesigner.FormsDesignerLoadException: System.ComponentModel.Design.Serialization.CodeDomSerializerException: The variable 'viewx' is either undeclared or was never assigned.
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadDesigner()
at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadAndDisplayDesigner()
at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadInternal(OpenedFile file, Stream stream)
at ICSharpCode.SharpDevelop.Gui.AbstractViewContentHandlingLoadErrors.Load(OpenedFile file, Stream stream)

What really stress me out is that the solution compile just fine . no problem at all. I've tried cleaning the solution,rebuild and recompile to check for errors. but still no errors.

Anyone? I've tried searching in google but i can't find anything.
Posted
Comments
Richard MacCutchan 21-Apr-13 5:46am    
I saw a similar post somewhere else recently. It seems this is a Visual Studio bug and you should report this to Microsoft.
yudhistira dewanata 22-Apr-13 5:48am    
wow that's sad. Then should i really use a different dataGridView variable for each different table? Do you know any other way to do this?
Richard MacCutchan 22-Apr-13 6:35am    
Just create the different DataGridView controls in the designer. If you manually edit the designer.cs file then it causes problems.
Thomas Duwe 22-Apr-13 5:17am    
Are you changing the automatically generated code in the <FormName>.Designer.cs?
yudhistira dewanata 22-Apr-13 5:45am    
Yes I change it.
Well, when i tried creating a new dataGridView dgdisplay2. (not an array)
and change the previously working code to dgdisplay2 it works just fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900