Extending ComboBox class, need to add my own items but when??

0

0to60

I'm extending the ComboBox class to create a combo for entering times like
in Outlook 2007. I'd like the combo to drop down and let the user select
from different times. I would like to set the interval for these times in
my app.config file though, which means I'll need to read in the interval
value before I load the items. Initially, I put the code that does this in
the constructor, but then when I tried to add the control to a form in the
designer, VS puked (because its trying to execute code to read the config
file; I guess you can't do this at design time). So, where do I put this
code? I don't wanna put it in OnPaint, because I only need it to go off
once. Where do I put this code so that it only goes off once?
 
J

Jeff Gaines

I'm extending the ComboBox class to create a combo for entering times like
in Outlook 2007. I'd like the combo to drop down and let the user select
from different times. I would like to set the interval for these times in
my app.config file though, which means I'll need to read in the interval
value before I load the items. Initially, I put the code that does this
in the constructor, but then when I tried to add the control to a form in
the designer, VS puked (because its trying to execute code to read the
config file; I guess you can't do this at design time). So, where do I
put this code? I don't wanna put it in OnPaint, because I only need it to
go off once. Where do I put this code so that it only goes off once?

I always have an Initialise function:

public class jclass()
{
InitializeComponents();
if(!this.DesignMode)
jclassInitialise();
}

private void jclassInitialise()
{
// set stuff up here
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top