R
Rimpinths
I'm new at developing user controls in C#, and one thing I've noticed
right off the bat is that the constructor gets called twice -- once at
design time, once at run time.
In short, I'm trying to develop a control derived from DataGridView. It
will have a default set of columns (but I don't want to create them via
the Properties window for various reasons) so I added a call to a
method AddColumns() in the constructor. But the columns end up getting
added twice -- once when I place the control in a form at design time,
and then again when I run the application.
I know that I can get around this by making an explicit call to
AddColumns() at runtime rather than putting it in the constructor. But
I like the fact that they show up at design time so that way I can see
what it's going to look like.
I tried adding an "initialized" flag in my constructor to prevent it
from callling AddColumns() twice, but that doesn't work because
apparently its design time value is reset at run time.
Any suggestions?
right off the bat is that the constructor gets called twice -- once at
design time, once at run time.
In short, I'm trying to develop a control derived from DataGridView. It
will have a default set of columns (but I don't want to create them via
the Properties window for various reasons) so I added a call to a
method AddColumns() in the constructor. But the columns end up getting
added twice -- once when I place the control in a form at design time,
and then again when I run the application.
I know that I can get around this by making an explicit call to
AddColumns() at runtime rather than putting it in the constructor. But
I like the fact that they show up at design time so that way I can see
what it's going to look like.
I tried adding an "initialized" flag in my constructor to prevent it
from callling AddColumns() twice, but that doesn't work because
apparently its design time value is reset at run time.
Any suggestions?