Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 21-Apr-13 0:14am
Comments
Richard MacCutchan at 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 at 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 at 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 at 22-Apr-13 5:17am
   
Are you changing the automatically generated code in the <FormName>.Designer.cs?
yudhistira dewanata at 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.
Thomas Duwe at 22-Apr-13 6:17am
   
If you change the code in the *.Designer.cs file you must be careful, what you change.
AFAIK the designer of Visual Studio is not capable of doing what you want (array-initialization of datagridviews).
Changing the name of some field/variable works just fine, but changing the way some fields are initialized/read/write
can result in errors.
yudhistira dewanata at 3-May-13 5:49am
   
Well, i guess I'll just create a new form for each datagridview.Thanks.

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

  Print Answers RSS
0 OriginalGriff 245
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 Afzaal Ahmad Zeeshan 120
4 DamithSL 115
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 21 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100