U
uncle.serge
In my app's form there are 8 instances of the same (functionally same)
grid which should handle data of URL type (same 3 columns, same
validations, same data classes, same visual behavior). Instead of
recreating in VS Designer this grid 8 times, I wrote a class UrlGrid
which inherits from standard DataGridView. In constructor of UrlGrid I
added 3 columns to it and set all properties. All is good for now and
the new control even automatically appears on Designer toolbox. But
when I drop this grid on a form and save it, all the columns are
doubled! I figured out why it's happening and fixed this but adding
the following in UrlGrid:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
private new DataGridViewColumnCollection Columns { get { return
base.Columns; } }
The DesignerSerializationVisibility attibutes tells Designer not to
save Coulmns property in MyForm.Designer.cs file. It helped a bit: in
terms of getting rid of doubling the coulmns. But still the columns
still are created in the form as form's variables. They are not added
to the grid instance but keep being generated on every change-and-save
of MyForm.cs[Design], resulting in extra 24 (8*3) "hanging" objects of
type DataGridViewColumn and about of 300 lines of code where their
numerous properties are set. By "hanging" I mean that these objects
are not used anywhere. But still, after 2 weeks of working on the
form, its designer-file has become more than 120,000 lines of code and
about 1MB in size, dramatically increasing total time of edit-save-
compile-run cycle.
So, the question: how to tell Designer not to generate Columns
variables for this custom grid class? I tried [Browsable(false)] and
some other attribute but it didn't help.
grid which should handle data of URL type (same 3 columns, same
validations, same data classes, same visual behavior). Instead of
recreating in VS Designer this grid 8 times, I wrote a class UrlGrid
which inherits from standard DataGridView. In constructor of UrlGrid I
added 3 columns to it and set all properties. All is good for now and
the new control even automatically appears on Designer toolbox. But
when I drop this grid on a form and save it, all the columns are
doubled! I figured out why it's happening and fixed this but adding
the following in UrlGrid:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
private new DataGridViewColumnCollection Columns { get { return
base.Columns; } }
The DesignerSerializationVisibility attibutes tells Designer not to
save Coulmns property in MyForm.Designer.cs file. It helped a bit: in
terms of getting rid of doubling the coulmns. But still the columns
still are created in the form as form's variables. They are not added
to the grid instance but keep being generated on every change-and-save
of MyForm.cs[Design], resulting in extra 24 (8*3) "hanging" objects of
type DataGridViewColumn and about of 300 lines of code where their
numerous properties are set. By "hanging" I mean that these objects
are not used anywhere. But still, after 2 weeks of working on the
form, its designer-file has become more than 120,000 lines of code and
about 1MB in size, dramatically increasing total time of edit-save-
compile-run cycle.
So, the question: how to tell Designer not to generate Columns
variables for this custom grid class? I tried [Browsable(false)] and
some other attribute but it didn't help.