S
Seth Gecko
Hi
I have a created a custom usercontrol which inherites an Excel like
usercontrol. In this usercontrol I have a custom property called
SpreadTemplate, which is an enum with (at the moment) two members
called None and Pipeline.
When I set this property at design time it sets up the activesheet with
a number of columns, rows, headers etc. This is all fine and working as
it is supposed to. The problem is that all this information gets
written to the [form].designer file, which makes it more or less
permanent. Meaning if I change the way SpreadTemplate sets up the form,
I will have to go back into design time and reset the property, before
it has any effect. The code in the [form].designer file looks like this
(in VB.Net, but the same happens using C#):
'
'CalsepSpecificSpread1
'
Me.CalsepSpecificSpread1.About = "2.5.2007.2005"
....
Me.SpreadTemplate = Pipeline
'
'CalsepSpecificSpread1_Sheet1
'
Me.CalsepSpecificSpread1_Sheet1.SheetName = "Pipeline"
Me.CalsepSpecificSpread1_Sheet1.ColumnCount = 7
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.RowCount = 2
Me.CalsepSpecificSpread1_Sheet1.RowCount = 1
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.AutoText =
FarPoint.Win.Spread.HeaderAutoText.Blank
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 0).Border =
ComplexBorder1
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 0).Value =
"x-Position"
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 1).Border =
ComplexBorder1
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 1).Value =
"y-Position"
....
Me.CalsepSpecificSpread1_Sheet1.Columns.Get(0).Width = 89.0!
....
And here comes another problem (besides having to go to the designer
and reapply the setting) and that is that some of the properties are
different at runtime (based on other settings), but these are
overridden by the ones above. Meaning when the line Me.SpreadTemplate =
Pipeline is done at runtime it might generate another text for
columnheader (0, 0), but this is then changed back into "x-position" by
the code generated in the [form].designer file. I have tried
experimenting with setting
<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
_
on the SpreadTemplate property, but this only affects whether the line
Me.SpreadTemplate = Pipeline gets written to the .designer file.
I realize that this is properly standard Visual Studio 2005, but still
it strikes me as pretty weird behaviour. Is there any way to deactivate
this or do anyone have another idea as how to handle this kind of
thing? Is it not good code practice to have one property set a number
of other properties? I could of course just do the SpreadTemplate =
Pipeline on form load or some other place that only gets called during
runtime, but I want to be able to see the changes at design time, so I
can design the rest of the form. I am really baffled at this behaviour,
please advise...!
Regards
....Seth
I have a created a custom usercontrol which inherites an Excel like
usercontrol. In this usercontrol I have a custom property called
SpreadTemplate, which is an enum with (at the moment) two members
called None and Pipeline.
When I set this property at design time it sets up the activesheet with
a number of columns, rows, headers etc. This is all fine and working as
it is supposed to. The problem is that all this information gets
written to the [form].designer file, which makes it more or less
permanent. Meaning if I change the way SpreadTemplate sets up the form,
I will have to go back into design time and reset the property, before
it has any effect. The code in the [form].designer file looks like this
(in VB.Net, but the same happens using C#):
'
'CalsepSpecificSpread1
'
Me.CalsepSpecificSpread1.About = "2.5.2007.2005"
....
Me.SpreadTemplate = Pipeline
'
'CalsepSpecificSpread1_Sheet1
'
Me.CalsepSpecificSpread1_Sheet1.SheetName = "Pipeline"
Me.CalsepSpecificSpread1_Sheet1.ColumnCount = 7
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.RowCount = 2
Me.CalsepSpecificSpread1_Sheet1.RowCount = 1
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.AutoText =
FarPoint.Win.Spread.HeaderAutoText.Blank
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 0).Border =
ComplexBorder1
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 0).Value =
"x-Position"
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 1).Border =
ComplexBorder1
Me.CalsepSpecificSpread1_Sheet1.ColumnHeader.Cells.Get(0, 1).Value =
"y-Position"
....
Me.CalsepSpecificSpread1_Sheet1.Columns.Get(0).Width = 89.0!
....
And here comes another problem (besides having to go to the designer
and reapply the setting) and that is that some of the properties are
different at runtime (based on other settings), but these are
overridden by the ones above. Meaning when the line Me.SpreadTemplate =
Pipeline is done at runtime it might generate another text for
columnheader (0, 0), but this is then changed back into "x-position" by
the code generated in the [form].designer file. I have tried
experimenting with setting
<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
_
on the SpreadTemplate property, but this only affects whether the line
Me.SpreadTemplate = Pipeline gets written to the .designer file.
I realize that this is properly standard Visual Studio 2005, but still
it strikes me as pretty weird behaviour. Is there any way to deactivate
this or do anyone have another idea as how to handle this kind of
thing? Is it not good code practice to have one property set a number
of other properties? I could of course just do the SpreadTemplate =
Pipeline on form load or some other place that only gets called during
runtime, but I want to be able to see the changes at design time, so I
can design the rest of the form. I am really baffled at this behaviour,
please advise...!
Regards
....Seth