Looking for a Method when a UI Object is first run.

ALT

Member
Joined
Feb 23, 2006
Messages
9
Programming Experience
10+
What I am looking for is a method that only executes when a UI Object ( Combobox, TextBox etc. ) is first ‘shown’ to the user at runtime, and does not run at design time.

NEW for example does not work because it seems to execute as soon as I drag my subclassed ComboBox onto a form. It ( The NEW method ) does execute later when the form is shown, but the earlier execution (when placed on the form ) causes problems.

I have written lots of Visual FoxPro programs and in that language there is an INIT method for each class that runs once and only once like I want here.

More FYI
I have two levels of sub classing from a Combo BOX:
ComboBox<|---Setup_CBX<|-- Setup_CBX_Player_Type
( I want some ‘special’ comboboxes on a Setup form for the player TYPE and MARK)
On of the things I want to do is load the combobox drop down list with information for the user to view. To complicate things there are some items in the ‘default’ list that I want to remove. What needs to be shown is changed at runtime. Therefore I’ve created a method in the Setup_CBX to all for possible display values to be loaded. In the Setup_CBX_Player_Type class I want to do the loading. I was hoping something like the following would work:

VB.NET:
   [COLOR=blue]Public[/COLOR] [COLOR=blue]Sub[/COLOR] New()
        [COLOR=blue]Me[/COLOR].Set_Possible_Item([COLOR=maroon]"Human"[/COLOR])
        [COLOR=blue]Me[/COLOR].Set_Possible_Item([COLOR=maroon]"Computer Level 1"[/COLOR])
        [COLOR=blue]Me[/COLOR].Set_Possible_Item([COLOR=maroon]"Computer Level 2"[/COLOR])
        [COLOR=blue]Me[/COLOR].Set_Possible_Item([COLOR=maroon]"Computer Level 3"[/COLOR])
        [COLOR=blue]Me[/COLOR].Set_Possible_Item([COLOR=maroon]"Not Playing"[/COLOR])
    [COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]

The result is that at design time the Item Collection list is already loaded ( not what I expected at all ) and at run time the Item collection list is doubled ( e.g. the list show everything twice). By the way just to make sure it is the design time work that is getting in my way I have tested the code in a code only matter ( via nUnit ) and it works fine.

What I am currently trying ( just started coding so it may not work ) is to create an “On_Init” method in the Setup_CBX_Player_Type method ( ? or Setup_CBX ? ) class that I will have the NEW code in the Form’s New method call. This will simulate what I am asking about here. Seems really kludgy too me, but I’m hoping it will work. Of course I need to find/figure out how to spin through each of the objects on the form to find those that have an On_Init method to run, that may be another question to post.


Any suggestions?
 
Back
Top