Best Way to Handle Multiple Widget Types

Hi,

Here is my problem:

My application handles multiple types of widgets e.g. a blue wudget, a red widget, a green widget etc

Each widget has some different properties that are unique to that widget and no other widget has them e.g. a blue one has hieght, a red one has weight etc

Now I want to build a form to edit widgets. Clearly as each widget has some unique attributes I cannot use one form (as there will be redundant fields on the form and it will look baaaad). So the question is how do I achieve this

Do I create a single base widget form class and then derive a new for for each widget from that i.e. have multiple forms Or do I create one form and in the code create the required tetxboxes etc dynamically

I like the idea of many formsjust because it is easier to layout the form using the IDE but I feel I am missing somethign there.....

Anyway I hope somebody can help me out here or point me to any examples that might help

Thanks,
Simon


Answer this question

Best Way to Handle Multiple Widget Types

  • kamal23

    OK, I think I understand...

    But it raises a question of how to dynamically create one of these objects.

    For example I have 2 sub classes
    Class BlueWidget
    End Class

    Class RedWidget
    End Class

    If I have a string with the widget type
    s = "BlueWidget"

    Is there a way to do something like

    myWidget = new 's' <===where s is the string containing the widget type

    How do I cast myWidget as the CONTENTS of a string

    So myWidget ends up being an instance of class BlueWidget
    That is I want a late bound type...(I think)

    I'm sorry my OO skills are cruddy and my VB,.NET skills even worse!!!! Hopefully a guru will take pity on me and help me out here!!!

    Thanks,

    Simon

  • Rajeshwari

    Sounds like an opportunity to take advatage of inheritance....

    Your widgets should inherit from a base widget that has all of the common methods and properties and the same with your forms....the base form has all of the common attributes and controls and each successive form is inherited from the base form....

    HTH



  • Best Way to Handle Multiple Widget Types