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??
Loading
sheir aliPosted Nov 23, 2010, 10:56 AM
Example
public partial class QueryForm : MvpFormBase<QueryFormPresenter, IQueryFormView>, IQueryFormView
switches to (for Design view)
public partial class QueryForm : Form
and the user-control goes from
public partial class UcQueryScreenFTAndOI : MvpControlBase<UCQueryScreenFTAndOIPresenter, IUCQueryScreenFTAndOIView>, IUCQueryScreenFTAndOIView
to (for design view)
public partial class UcQueryScreenFTAndOI : UserControl
So I do not think that would be an issue for the Designer since as far as it concerned, my winform/usercontrol inherits from the windows base classes.
Sam HobbsPosted Nov 19, 2010, 6:45 PM
sheir aliPosted Nov 19, 2010, 5:36 PM
In Design view of the form, I can see the list of magically created DGV in the Property list of the form but they do not show up on the form itself (when there are more than the "initial" 6 it created). The 6 that it created are the Grids within the UserControl (each instance of the UC has 3 grids).
I used Document View (in the Designer) to see how controls are on the Form and those magically created DGV do not show up in the Document View at all!
But if selected in the Property window (ie say I selected dataGridView13) then I see that a DGV in one of the usercontrol has been selected.
If I make a change to the Form and save then go back into Designer view, there it creates another 6 instances and so now I would have 12 in the designer.cs file.
Really truly bizarre behaviour.
Have zipped up both designer.cs files (after I had cleaned the form designer file)
Sam HobbsPosted Nov 19, 2010, 5:16 PM
you say that there are 3, then every time 6, then nearly 600. I don't understand that; is it always 6 or not?
There is probably something incorrect in the designer.cs file but I don't know if it is the file for the form or the usercontrol since your description is unclear. If you don't mind uploading the source code then upload at least the designer.cs file for either the form or the usercontrol.