Click here to Skip to main content
15,892,643 members
Home / Discussions / C#
   

C#

 
AnswerRe: WMPlayer Dll Import Question Pin
Ravi Bhavnani10-Sep-11 17:12
professionalRavi Bhavnani10-Sep-11 17:12 
QuestionManaging multiple controls [modified] Pin
Electric Eddy9-Sep-11 13:51
Electric Eddy9-Sep-11 13:51 
AnswerRe: Managing multiple controls Pin
Philippe Mori9-Sep-11 14:21
Philippe Mori9-Sep-11 14:21 
AnswerRe: Managing multiple controls Pin
BillWoodruff9-Sep-11 14:29
professionalBillWoodruff9-Sep-11 14:29 
AnswerRe: Managing multiple controls Pin
Eddy Vluggen10-Sep-11 12:57
professionalEddy Vluggen10-Sep-11 12:57 
GeneralRe: Managing multiple controls Pin
BillWoodruff10-Sep-11 20:09
professionalBillWoodruff10-Sep-11 20:09 
GeneralRe: Managing multiple controls Pin
Eddy Vluggen11-Sep-11 1:37
professionalEddy Vluggen11-Sep-11 1:37 
GeneralRe: Managing multiple controls Pin
BillWoodruff11-Sep-11 2:44
professionalBillWoodruff11-Sep-11 2:44 
Eddy Vluggen wrote:
Clearing the controls-collection doesn't discard the controls, it merely clears the controls-collection of the container, and yes, I'm reusing that container to show something else that's already in memory.
You interpret my use of the word 'discard' as if I had said 'Dispose' which is an incorrect interpretation. Of course the Controls, and even their internal "state" is not "lost," when they are removed from a ControlCollection, by 'Clear().'

What is "discarded" is the entire "design and intelligence" that (hopefully) went into creating a collection of Controls on a Panel (or Form, or UserControl). Which includes placement, z-order, tab-order, docking, anchoring, etc.

To "flush" the ControlCollection, just to present something else is just a ridiculously bad programming practice when there are such simpler alternatives.

Yes, you could write code to copy all the Controls in a Panel into an Array (using CopyTo(Control[], index)), and you could loop through that array, and, hopefully, restore the Panel's controls to a previous configuration: but what a waste of time and code ... when all you have to do is hide the whole Panel, or fill it, temporarily, with some other container that hides the 'original controls.'

And to design a ControlCollection to be used once and discarded: I can't imagine what kind of real-world scenario would call for such an implementation.

Forms are 'expensive,' and I think the way you have advocated using them here is an example of how to mis-use Forms.

Good programming practice uses "lighter-weight" objects for "lighter weight" tasks. The days of "MDI" are gone (praise be, except for the undoubted 'legacy' applications that will use that architecture until doomsday), and the use of Forms within Forms is just bad practice.

yrs, Bill
"Is it a fact - or have I dreamt it - that, by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time? Rather, the round globe is a vast head, a brain, instinct with intelligence!" - Nathanial Hawthorne, House of the Seven Gables

GeneralRe: Managing multiple controls Pin
Eddy Vluggen11-Sep-11 2:52
professionalEddy Vluggen11-Sep-11 2:52 
QuestionVS2008 WMP Issue wirh user privileges Pin
Martin Wasley9-Sep-11 12:22
Martin Wasley9-Sep-11 12:22 
AnswerRe: VS2008 WMP Issue wirh user privileges Pin
TheGreatAndPowerfulOz12-Sep-11 11:34
TheGreatAndPowerfulOz12-Sep-11 11:34 
QuestionJust wondering..c# online Pin
stephen.darling9-Sep-11 6:48
stephen.darling9-Sep-11 6:48 
AnswerRe: Just wondering..c# online Pin
AspDotNetDev9-Sep-11 7:13
protectorAspDotNetDev9-Sep-11 7:13 
GeneralRe: Just wondering..c# online Pin
stephen.darling9-Sep-11 7:17
stephen.darling9-Sep-11 7:17 
GeneralRe: Just wondering..c# online Pin
AspDotNetDev9-Sep-11 7:32
protectorAspDotNetDev9-Sep-11 7:32 
GeneralRe: Just wondering..c# online Pin
stephen.darling9-Sep-11 8:12
stephen.darling9-Sep-11 8:12 
GeneralRe: Just wondering..c# online Pin
Richard MacCutchan9-Sep-11 21:28
mveRichard MacCutchan9-Sep-11 21:28 
GeneralRe: Just wondering..c# online Pin
stephen.darling10-Sep-11 3:04
stephen.darling10-Sep-11 3:04 
AnswerRe: Just wondering..c# online Pin
BillWoodruff9-Sep-11 14:37
professionalBillWoodruff9-Sep-11 14:37 
GeneralRe: Just wondering..c# online Pin
stephen.darling10-Sep-11 3:04
stephen.darling10-Sep-11 3:04 
AnswerRe: Just wondering..c# online Pin
jschell10-Sep-11 8:14
jschell10-Sep-11 8:14 
GeneralRe: Just wondering..c# online Pin
stephen.darling10-Sep-11 8:24
stephen.darling10-Sep-11 8:24 
QuestionPacking optimisation code/alogrithm required Pin
_awatts9-Sep-11 2:37
_awatts9-Sep-11 2:37 
AnswerRe: Packing optimisation code/alogrithm required Pin
Luc Pattyn9-Sep-11 4:12
sitebuilderLuc Pattyn9-Sep-11 4:12 
GeneralRe: Packing optimisation code/alogrithm required Pin
_awatts9-Sep-11 5:45
_awatts9-Sep-11 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.