Re: User control constructor called twice
- From: "Dave Sexton" <dave@jwa[remove.this]online.com>
- Date: Wed, 22 Nov 2006 00:58:07 -0500
Hi,
I'm so sorry - I accidentally gave you code overloading the wrong method :|
The following code works just fine:
public class CustomDataGridView : DataGridView
{
protected override void OnCreateControl()
{
if (Site == null || !Site.DesignMode)
{
Columns.Add("Test 1", "Header 1");
Columns.Add("Test 2", "Header 2");
}
base.OnCreateControl();
}
}
Yeah, I guess it does make sense that the constructor gets called at
design time, and then of course at run time. What I don't get is why
the constructor gets called twice for the same instance of that
control? Why doesn't the design time instance get thrown out and a new
one created at run time? How can you even call a constructor twice for
the same instance?
You can't call a constructor twice on the same instance. The runtime
instance and design-time instance are not the same. When you start your
application, even with a debugger attached, it will run in its own process.
<snip - sorry - >
--
Dave Sexton
.
- Follow-Ups:
- Re: User control constructor called twice
- From: Rimpinths
- Re: User control constructor called twice
- References:
- User control constructor called twice
- From: Rimpinths
- Re: User control constructor called twice
- From: Rimpinths
- Re: User control constructor called twice
- From: Dave Sexton
- Re: User control constructor called twice
- From: Rimpinths
- User control constructor called twice
- Prev by Date: Re: GUI Buttons like VISTA
- Next by Date: Re: Thread ending
- Previous by thread: Re: User control constructor called twice
- Next by thread: Re: User control constructor called twice
- Index(es):