sheir ali

sheir ali

  • NA
  • 10
  • 0

WinForm with UserControl containing DataGridView causes Designer issue

Nov 19 2010 4:34 PM

Hello,
I have a very strange issue and am not sure why it is happening or how to prevent it.
Envionment:
.NET Framework 3.5
WinForm application
C#
VS2008 Pro
Issue:
I have a WinForm containing a TabControl which has a custom usercontrol on two of its TabPage.
The usercontrol i created contains 3 DataGridView controls.
Everytime I go into Desiger of my WinForm, I see that there are SIX (3 * 2) instances of a DataGridView control created.
They are all numbered such as dataGridView13, dataGridView14, etc...
Along each of those DataGridView instances, the associated DataGridViewTextBoxColumn and DataGridViewCellStyle instances are also created. 
Pretty soon I had nearly 600 DataGridView instances in the MyWinForm.Designer.cs file!!

Why is this happening and more importantly how to prevent it???
Anyone has seen something like this before??

Answers (4)