DesignMode problem 
Author Message
 DesignMode problem

I have derived a control form combo box, say PaymentTypeCombo. in the
constructor I have
if (!DesignMode)
{
    Items.Add("Cheque");
    Items.Add("Cash");
    Items.Add("Credit");

Quote:
}

the problem is it adds the items in design mode and they get saved in the
InitializeComponent of the form and when I show the form containing the
combo I have two sets of payment types in the combo.

Help !!!



Tue, 23 Nov 2004 09:04:18 GMT  
 DesignMode problem

Quote:
> I have derived a control form combo box, say PaymentTypeCombo. in the
> constructor I have
> if (!DesignMode)
> {
>     Items.Add("Cheque");
>     Items.Add("Cash");
>     Items.Add("Credit");
> }

> the problem is it adds the items in design mode and they get saved in the
> InitializeComponent of the form and when I show the form containing the
> combo I have two sets of payment types in the combo.

I've had the same problem. My solution (probably not the only one) was
populating the items in the DropDown event (which is never called in design
mode):

protected override void OnDropDown(EventArgs e)
{
  if (Items.Count == 0)
  {
     Items.Add("Cheque");
     Items.Add("Cash");
     Items.Add("Credit");
  }

Quote:
}

However this might cause some problems when DropDownStyle is DropDownList,
because you cannot use SelectedIndex property as long as the items are not
populated.

Jens



Tue, 23 Nov 2004 22:41:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DesignMode in constructor

2. Implementing ISite to have access to DesignMode indicator

3. How To: Selected Item or Items in Web Browser (in designMode)

4. Is DesignMode property working???

5. designmode appearance & code

6. ATL DesignMode

7. Move the caret in designMode (ihtmldocument2)

8. problems problems problems

9. Problems, problems, problems!

10. Problems, problems problems

11. Problems, Problems, Problems

12. VC6 to VC7 migration problem (problem with ATL and MFC)

 

 
Powered by phpBB® Forum Software