Tuesday, April 29, 2008

Hide an element from the combo box

Question
I have an enum with values Element1, Element2 and Element3. Now this enum is being used on two different locations what the requirement is that i have to add another element Element4 in to the enum but this should only reflect on one location.

Answer
Let say you you two forms where this enum is reflected, namely Form1 and Form2. In order to hide an element from Form1 and continue showing it on Form2 go to form design and then access that combo box control. Override the enter() method of that combo box and write this line to delete the element from it.

combobox:enter()
{
super();
this.delete(enum2str(BaseEnum::Element4));
}

6 comments:

  1. İt doesn't work
    when I delete item I can't select the other item properly

    but , thanks for your information

    ReplyDelete
  2. HI, and it also returns the wrong enum value

    ReplyDelete
  3. this work only if you remove last enum value otherwise it shift enum value

    ReplyDelete
  4. exactly -- this is worthless for the most part.

    ReplyDelete
  5. do not discourage a valuable finding or suggestion.if needed use it else get away.

    ReplyDelete