944,081 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 464
  • C# RSS
Nov 2nd, 2009
0

Toolbox vs manual creation

Expand Post »
With apologies to ddanbe, I just have a question regarding using the IDE toolbox vs programmatically creating form objects at run time. I use to fall into the habit of only using the tool box to create from objects such as buttons or picture boxes but have now started to create them in the form constructor. For example on my last project I needed to create 26 buttons, with each button representing the alphabet. I found that I could create them with less code and have all 26 buttons use one click() method. Normally I would have dragged and dropping each button from the tool box, modified its properties and created a cick() method for each button.

However this does make the form code look a bit messy since it is not in the form.designer.cs class.

I know it probably depends on circumstance but what method is better than other? Does it matter?
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
RunTimeError is offline Offline
54 posts
since Oct 2009
Nov 2nd, 2009
0
Re: Toolbox vs manual creation
No problem
Depends indeed.
If I have 2 or 3 buttons and some other controls, I let the IDE do his work. But in a case of 26 or more buttons it pays off to create them manually in a loop, so I guess you are right the way you like to do it.
The form.designer.cs class is just a part of the form class by the way!
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Nov 2nd, 2009
0
Re: Toolbox vs manual creation
As danny suggested it depends. The only consideration I want to throw in here is cleanup. Be sure to clean up and Dispose() of any controls you create that may have not been added to the control list of the form.
Last edited by sknake; Nov 2nd, 2009 at 6:56 pm.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Which will be faster?
Next Thread in C# Forum Timeline: how to establish VPN between 2 PC through code?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC