Windows Develop Bookmark and Share   
 index > Windows Forms General > Some controls not in Form.Controls
 

Some controls not in Form.Controls

Hello,

I have a form (VS2005) with ToolStrip, StatusStrip and DataGridView controls, but Form.Controls contains only 1 element which is the ToolStrip. The StatusStrip and DataGridView are not in the collection. For both those controls, FindForm method returns the correct form. Any idea why?

TIA

Yoav_by  Thursday, October 01, 2009 12:50 PM
Maybeall of your controls are in ToolStripContainer and Form.Controls isreturning ToolStripContainer controlnot ToolStrip.

  • Marked As Answer byYoav_by Thursday, October 01, 2009 1:32 PM
  •  
Tamer Oz  Thursday, October 01, 2009 1:29 PM

Do you add StatusStrip and DataGridView after calling Form.Controls?

Tamer Oz  Thursday, October 01, 2009 1:05 PM

Do you add StatusStrip and DataGridView after calling Form.Controls?


No, all controls were added from the form designer.
Yoav_by  Thursday, October 01, 2009 1:23 PM
Maybeall of your controls are in ToolStripContainer and Form.Controls isreturning ToolStripContainer controlnot ToolStrip.

  • Marked As Answer byYoav_by Thursday, October 01, 2009 1:32 PM
  •  
Tamer Oz  Thursday, October 01, 2009 1:29 PM
In this scenario if I am right,

Form is containing ToolStripContainer control and ToolStripContainer control is containing your 3 controls.

Controls property does not return all child controls.

To search in all child controls you can use Find method of Controls collection.
Tamer Oz  Thursday, October 01, 2009 1:33 PM
Maybeall of your controls are in ToolStripContainer and Form.Controls isreturning ToolStripContainer controlnot ToolStrip.


Aha! That's what happened. Thanks a lot.
Yoav_by  Thursday, October 01, 2009 1:33 PM

You can use google to search for other answers

Custom Search

More Threads

• Performance. Shall we?
• MenuStrip control and Visual Inheritance
• trouble resizing a panel at runtime
• waveform display control?
• Live Video tranfer
• Changing the PrinterName setting is causing an invalid handle error
• Two comboboxes, One Datatable
• Controls flicker (strange)
• Toolstrip: strange behaviour after items adding programmatically and at design time
• Using Word templates to construct document dynamically