Click here to Skip to main content
15,891,863 members
Home / Discussions / C#
   

C#

 
Questionstatic method calling a non static Pin
PaulaM31-May-06 3:59
PaulaM31-May-06 3:59 
AnswerRe: static method calling a non static Pin
led mike31-May-06 4:50
led mike31-May-06 4:50 
AnswerRe: static method calling a non static Pin
Wjousts31-May-06 4:53
Wjousts31-May-06 4:53 
Questionrun time error : "Catastrophic failure" ,,, what can be the problem Pin
Member 227165531-May-06 3:57
Member 227165531-May-06 3:57 
Questionwinforms question Pin
batmike200031-May-06 3:41
batmike200031-May-06 3:41 
AnswerRe: winforms question [modified] Pin
Dustin Metzgar31-May-06 5:37
Dustin Metzgar31-May-06 5:37 
GeneralRe: winforms question Pin
Josh Smith31-May-06 6:00
Josh Smith31-May-06 6:00 
GeneralRe: winforms question [modified] Pin
Dustin Metzgar31-May-06 6:30
Dustin Metzgar31-May-06 6:30 
How about reflection then? You can do a GetMembers() on the form's Type and look for fields. See if that field type is an implementation of IComponent, and add it to the list.

List<IComponent> components = new List<IComponent>();
foreach (MemberInfo mi in this.GetType().GetMembers()) {
   if (mi.MemberType == MemberTypes.Field) {
      if (mi.DeclaringType.GetInterface("IComponent") != null) {
         FieldInfo fi = mi as FieldInfo;
         components.Add((IComponent)fi.GetValue(this));
      }
   }
}


I haven't tested this code, but it should be pretty close.
Last modified: Wednesday, May 31, 2006 12:25:05 PM --

GeneralRe: winforms question [modified] Pin
batmike200031-May-06 20:25
batmike200031-May-06 20:25 
GeneralRe: winforms question [modified] Pin
batmike20002-Jun-06 0:00
batmike20002-Jun-06 0:00 
GeneralRe: winforms question [modified] Pin
Dustin Metzgar2-Jun-06 1:46
Dustin Metzgar2-Jun-06 1:46 
Questiondatagridview comboboxcolumn Pin
kjosh31-May-06 3:33
kjosh31-May-06 3:33 
QuestionHas anyone ever y used the DTE object? Pin
Ista31-May-06 3:33
Ista31-May-06 3:33 
QuestionChange StatusBar backColor Pin
Darren_31-May-06 3:10
Darren_31-May-06 3:10 
AnswerRe: Change StatusBar backColor Pin
stancrm31-May-06 3:53
stancrm31-May-06 3:53 
GeneralRe: Change StatusBar backColor Pin
Darren_31-May-06 13:54
Darren_31-May-06 13:54 
QuestionHow to off WebBrowser SCRIPT ERROR message? Pin
Dima Filipiuk31-May-06 3:04
Dima Filipiuk31-May-06 3:04 
QuestionnGen Pin
subburaj.sabapathy31-May-06 2:25
subburaj.sabapathy31-May-06 2:25 
AnswerRe: nGen Pin
Guffa31-May-06 2:51
Guffa31-May-06 2:51 
QuestionUrgent.... Pin
compdesign31-May-06 2:22
compdesign31-May-06 2:22 
AnswerRe: Urgent.... Pin
stancrm31-May-06 2:28
stancrm31-May-06 2:28 
QuestionRecognize Managed DLL from Unmanaged ! Pin
User 209307331-May-06 2:08
User 209307331-May-06 2:08 
AnswerRe: Recognize Managed DLL from Unmanaged ! Pin
S. Senthil Kumar31-May-06 6:14
S. Senthil Kumar31-May-06 6:14 
GeneralRe: Recognize Managed DLL from Unmanaged ! Pin
User 209307331-May-06 19:17
User 209307331-May-06 19:17 
QuestionorlRegarding Crystal Reports Pin
A.Grover31-May-06 1:47
A.Grover31-May-06 1:47 

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.