1

I'm creating a form with pictureBoxes, buttons and txtboxes. My question is: If i create the controls programatically in the load event, will the performance will be the same as if my controls are created with the toolBox?

Which of these two methods are better?

Thank you

mlaribi
  • 699
  • 1
  • 10
  • 18
  • 2
    In general the performance will be the same. When you use the Forms Designer, the result is still code just like you might put in the Form's Load event handler. The code just runs at a different time. Look in Form1.Designer.vb to see the code created by the designer for Form1 (you may need to select "Show All Files" in Solution Explorer to see the designer files. – Blackwood Apr 11 '15 at 21:08
  • 1
    http://stackoverflow.com/a/2522999/17034 – Hans Passant Apr 11 '15 at 21:47
  • I rolled back your edit. Adding [Solved] to the title is inappropriate here. If you found a solution you want to share, post it as an answer to your question. If the question is no longer relevant, delete it. – Ken White Jun 22 '15 at 18:18
  • Now it's solved ahah – mlaribi Jul 07 '15 at 19:16

1 Answers1

0

Performance should be identical. Visual studio is actually generating the code to "dynamically" create those controls for you, that's whats inside the .designer.vb files for each form. If you add some controls and design time and open those designer code files you will see the exact same type of code that you would have to write yourself to create a control at runtime. It may be a little more verbose, or oddly formatted, but it is doing the same thing.

Bradley Uffner
  • 16,641
  • 3
  • 39
  • 76
  • I came to the same conclusion with stackoverflow.com/a/2522999/17034 given By @Hans Passant in the comments if the question But the thank you for the help – mlaribi Jun 22 '15 at 19:23