How to optimize User interface creation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siilexx
    New Member
    • Aug 2010
    • 19

    #1

    How to optimize User interface creation

    Hello,

    I'm building an interface showing many users controls (mainly Labels and Buttons) but the result is rather slow.

    Here is a basic sample of the code:

    Code:
    Panel myPanel = new Panel();
    
    int nbrPPL=15;
    for (int k=0; k < nbrPPL; k++)
    {
       Case[k] = new Label();
       Case[k].Location=...
       Case[k].Size=...
       Case[k].Name=...
    
       CaseH[k] = new Label();
       CaseH[k].Location=...
    
       CaseT[k] = new Label();
       CaseT[k].Location=...
    
       myPanel.Controls.Add(Case[k]);
       myPanel.Controls.Add(CaseT[k]);
       myPanel.Controls.Add(CaseH[k]);
    
    }
    
    Controls.Add(myPanel);
    Could you please advise on the best way to optimize my code ?

    Thank you
  • Aimee Bailey
    Recognized Expert New Member
    • Apr 2010
    • 197

    #2
    Why not use a control that is designed to deal with a lot of data like the DataGridView? :) that will allow you to have buttons next to each person.

    Aimee.

    Comment

    • siilexx
      New Member
      • Aug 2010
      • 19

      #3
      Hello,
      I'm using both buttons and label on the same line, and different color on each line which can be changed dynamically by the user (see this screenshot ).

      Do you think that a DataGridView could handle this easily ?

      Thank you

      Comment

      • Aimee Bailey
        Recognized Expert New Member
        • Apr 2010
        • 197

        #4
        Most of what you are doing there can be done using the DataGridView hun, also on a side note, if you wanted more customization, you may find WPF a wonderful route to take seeing as it uses directx to draw its interface.

        Aimee

        Comment

        • siilexx
          New Member
          • Aug 2010
          • 19

          #5
          Do you have some kind of tutorial explaining how to use or create controls similar to a windows form "Label" using directx ?
          Thank you

          Comment

          Working...