Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / FormCollection.cs / 1305376 / FormCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms {
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
///
///
///
/// This is a read only collection of Forms exposed as a static property of the
/// Application class. This is used to store all the currently loaded forms in an app.
///
///
public class FormCollection : ReadOnlyCollectionBase {
internal static object CollectionSyncRoot = new object();
///
///
///
/// Gets a form specified by name, if present, else returns null. If there are multiple
/// forms with matching names, the first form found is returned.
///
///
public virtual Form this[string name] {
get {
if (name != null) {
lock (CollectionSyncRoot) {
foreach(Form form in InnerList) {
if (string.Equals(form.Name, name, StringComparison.OrdinalIgnoreCase)) {
return form;
}
}
}
}
return null;
}
}
///
///
///
/// Gets a form specified by index.
///
///
public virtual Form this[int index] {
get {
Form f = null;
lock (CollectionSyncRoot) {
f = (Form) InnerList[index];
}
return f;
}
}
///
/// Used internally to add a Form to the FormCollection
///
internal void Add(Form form) {
lock (CollectionSyncRoot) {
InnerList.Add(form);
}
}
///
/// Used internally to check if a Form is in the FormCollection
///
internal bool Contains(Form form)
{
bool inCollection = false;
lock (CollectionSyncRoot)
{
inCollection = InnerList.Contains(form);
}
return inCollection;
}
///
/// Used internally to add a Form to the FormCollection
///
internal void Remove(Form form) {
lock (CollectionSyncRoot) {
InnerList.Remove(form);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms {
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
///
///
///
/// This is a read only collection of Forms exposed as a static property of the
/// Application class. This is used to store all the currently loaded forms in an app.
///
///
public class FormCollection : ReadOnlyCollectionBase {
internal static object CollectionSyncRoot = new object();
///
///
///
/// Gets a form specified by name, if present, else returns null. If there are multiple
/// forms with matching names, the first form found is returned.
///
///
public virtual Form this[string name] {
get {
if (name != null) {
lock (CollectionSyncRoot) {
foreach(Form form in InnerList) {
if (string.Equals(form.Name, name, StringComparison.OrdinalIgnoreCase)) {
return form;
}
}
}
}
return null;
}
}
///
///
///
/// Gets a form specified by index.
///
///
public virtual Form this[int index] {
get {
Form f = null;
lock (CollectionSyncRoot) {
f = (Form) InnerList[index];
}
return f;
}
}
///
/// Used internally to add a Form to the FormCollection
///
internal void Add(Form form) {
lock (CollectionSyncRoot) {
InnerList.Add(form);
}
}
///
/// Used internally to check if a Form is in the FormCollection
///
internal bool Contains(Form form)
{
bool inCollection = false;
lock (CollectionSyncRoot)
{
inCollection = InnerList.Contains(form);
}
return inCollection;
}
///
/// Used internally to add a Form to the FormCollection
///
internal void Remove(Form form) {
lock (CollectionSyncRoot) {
InnerList.Remove(form);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LexicalChunk.cs
- COMException.cs
- CompatibleComparer.cs
- AccessKeyManager.cs
- BaseCodePageEncoding.cs
- BuildResult.cs
- UnknownBitmapEncoder.cs
- VectorAnimationUsingKeyFrames.cs
- WebPartDisplayMode.cs
- ContentPlaceHolder.cs
- RenameRuleObjectDialog.cs
- XmlUtf8RawTextWriter.cs
- ReflectTypeDescriptionProvider.cs
- ServiceOperation.cs
- CompilerWrapper.cs
- Geometry3D.cs
- BuildResultCache.cs
- MsmqHostedTransportConfiguration.cs
- GPRECTF.cs
- InteropExecutor.cs
- EntityCodeGenerator.cs
- Brush.cs
- ServiceProviders.cs
- XhtmlConformanceSection.cs
- UrlPath.cs
- GPPOINTF.cs
- X509UI.cs
- ApplicationManager.cs
- KeyManager.cs
- DataList.cs
- PeerCollaborationPermission.cs
- UnmanagedBitmapWrapper.cs
- ISFClipboardData.cs
- SchemaHelper.cs
- parserscommon.cs
- MenuItemStyle.cs
- EditorPartCollection.cs
- SessionStateSection.cs
- WorkflowInstance.cs
- ComNativeDescriptor.cs
- Rect3D.cs
- DomNameTable.cs
- DateTimeParse.cs
- ADMembershipProvider.cs
- PenCursorManager.cs
- CodeFieldReferenceExpression.cs
- WebServiceData.cs
- MultiTrigger.cs
- PeerCollaborationPermission.cs
- OdbcConnectionStringbuilder.cs
- TargetInvocationException.cs
- BadImageFormatException.cs
- XmlTextWriter.cs
- AssemblyNameProxy.cs
- WCFBuildProvider.cs
- Semaphore.cs
- UIServiceHelper.cs
- ExpandedProjectionNode.cs
- SafeWaitHandle.cs
- WebPageTraceListener.cs
- PhonemeEventArgs.cs
- XmlSchemaSubstitutionGroup.cs
- RelationshipEndCollection.cs
- ExpressionParser.cs
- EntityDataSourceSelectedEventArgs.cs
- AmbientEnvironment.cs
- BindingEditor.xaml.cs
- ItemMap.cs
- AutomationPeer.cs
- CustomErrorCollection.cs
- NegatedCellConstant.cs
- BlobPersonalizationState.cs
- PageAdapter.cs
- ContextDataSource.cs
- ConnectionPoint.cs
- XmlDataFileEditor.cs
- URI.cs
- DropShadowEffect.cs
- ConfigurationPropertyAttribute.cs
- DetailsViewInsertEventArgs.cs
- AutomationEventArgs.cs
- ScriptReference.cs
- MasterPageBuildProvider.cs
- HtmlInputRadioButton.cs
- PointHitTestResult.cs
- ClientType.cs
- selecteditemcollection.cs
- TextEditorCopyPaste.cs
- SchemaCollectionPreprocessor.cs
- DefaultMemberAttribute.cs
- SmtpNetworkElement.cs
- IdnMapping.cs
- wgx_render.cs
- TextTrailingCharacterEllipsis.cs
- Figure.cs
- HtmlLink.cs
- SecurityCriticalDataForSet.cs
- LazyTextWriterCreator.cs
- EntityDataSourceValidationException.cs
- FlatButtonAppearance.cs