dynamic winforms UI

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peted

    dynamic winforms UI

    Can anyone suggest a best practice approach to building a dynamic
    winforms UI.

    Just as an example somehting like a billing application where you
    enter a customer billing data and the billing options, the UI and the
    winform controls you have visible are dynamic and can change as
    information is entered, so that there is a dependency between between
    the data you enter and how other controls react, and/or are even
    selectable

    In addtion the UI should be dynamic in that it can vary when it is
    first shown. So the problems i imagine with this is the winforms is
    built by a designer, and that makes its layout fixed.
    So should i look at multiple forms, and show the relevant one only or
    is a better approach to build the UI in code and not use the designer
    at all.

    Does anyone have any info on a best practice approach for this sort of
    task or any advice or any tutorials etc.


    thanks for any info

    Peted
  • Alberto Poblacion

    #2
    Re: dynamic winforms UI

    "Peted" wrote in message news:5lk064prk2 7nqbhla9om0tnlf jj523cche@4ax.c om...
    Can anyone suggest a best practice approach to building a dynamic
    winforms UI.
    >
    Just as an example somehting like a billing application where you
    enter a customer billing data and the billing options, the UI and the
    winform controls you have visible are dynamic and can change as
    information is entered, so that there is a dependency between between
    the data you enter and how other controls react, and/or are even
    selectable
    >
    In addtion the UI should be dynamic in that it can vary when it is
    first shown. So the problems i imagine with this is the winforms is
    built by a designer, and that makes its layout fixed.
    If you look at the designer-generated code, you will find out that the
    designer is actually writing code which generates the layout dynamically
    when it is executed from the form constructor.
    There is nothing to prevent you from writing code like that and
    executing it yourself, thereby generating a dynamic layout. For instance, to
    add a new textbox to the form you do this:
    TextBox t = new TextBox();
    t.Top = 200; //Change properties as needed
    this.Controls.A dd(t);

    Basically, whatever you add to the Controls collection of the Form will
    appear on screen. Of course, you can also remove elements from the
    collection.


    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: dynamic winforms UI

      On Jun 23, 10:23 pm, Peted wrote:
      Can anyone suggest a best practice approach to building a dynamic
      winforms UI.
      >
      Just as an example somehting like a billing application where you
      enter a customer billing data and the billing options, the UI and the
      winform controls you have visible are dynamic and can change as
      information is entered, so that there is a dependency between between
      the data you enter and how other controls react, and/or are even
      selectable
      >
      In addtion the UI should be dynamic in that it can vary when it is
      first shown. So the problems i imagine with this is the winforms is
      built by a designer, and that makes its layout fixed.
      So should i look at multiple forms, and show the relevant one only or
      is a better approach to build the UI in code and not use the designer
      at all.
      >
      Does anyone have any info on a best practice approach for this sort of
      task or any advice or any tutorials etc.
      >
      thanks for any info
      >
      Peted
      You can do the UI as dynamic as you want. You can read the description
      from a XML file and create the controls at runtime.
      you would need a good framework though to handle the events of such a
      form.
      We use something similar where all the interface is defined in a XML
      file.
      Take a look at the Model View Presenter pattern as a way to handle the
      user interaction

      Comment

      Working...