Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / FormCollection.cs / 1 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewCellCancelEventArgs.cs
- TemplateBindingExpressionConverter.cs
- ResourceSetExpression.cs
- ManagementObjectCollection.cs
- ButtonBase.cs
- Panel.cs
- ProxyGenerationError.cs
- DataAdapter.cs
- ToolStripControlHost.cs
- Select.cs
- TemplateBamlTreeBuilder.cs
- PrivilegeNotHeldException.cs
- RenderCapability.cs
- Rect.cs
- DateTimeFormatInfoScanner.cs
- NativeMethods.cs
- returneventsaver.cs
- SchemaLookupTable.cs
- HTTPNotFoundHandler.cs
- HuffModule.cs
- TemplateNodeContextMenu.cs
- PointConverter.cs
- Section.cs
- Visitor.cs
- KeyedHashAlgorithm.cs
- CustomBindingCollectionElement.cs
- PrintDialog.cs
- SqlStatistics.cs
- SymbolTable.cs
- ProgressBar.cs
- ClientBase.cs
- ObjectSecurity.cs
- WithParamAction.cs
- SqlRewriteScalarSubqueries.cs
- HtmlForm.cs
- HtmlTableCell.cs
- smtpconnection.cs
- FormView.cs
- UnmanagedBitmapWrapper.cs
- ContentDisposition.cs
- StreamMarshaler.cs
- DocumentPageHost.cs
- AsymmetricSecurityBindingElement.cs
- CheckBoxBaseAdapter.cs
- CustomAttributeSerializer.cs
- MetadataItemEmitter.cs
- ScaleTransform.cs
- SamlSubject.cs
- Command.cs
- NameValueCollection.cs
- AppSecurityManager.cs
- StorageAssociationSetMapping.cs
- PassportPrincipal.cs
- DataGridViewComponentPropertyGridSite.cs
- DefaultParameterValueAttribute.cs
- DoubleAnimationClockResource.cs
- DependencyPropertyDescriptor.cs
- CommonObjectSecurity.cs
- PageTheme.cs
- Mapping.cs
- Types.cs
- SpotLight.cs
- AudioFileOut.cs
- SyndicationElementExtension.cs
- CodeExpressionCollection.cs
- QuadraticBezierSegment.cs
- HostingEnvironmentException.cs
- DesigntimeLicenseContextSerializer.cs
- ChtmlTextWriter.cs
- ObjectAnimationUsingKeyFrames.cs
- RemoteEndpointMessageProperty.cs
- MailWebEventProvider.cs
- CodeComment.cs
- SoapIgnoreAttribute.cs
- Overlapped.cs
- BindingManagerDataErrorEventArgs.cs
- ParameterToken.cs
- UInt32Storage.cs
- MouseButton.cs
- HandleCollector.cs
- GradientStop.cs
- OleDbReferenceCollection.cs
- BindToObject.cs
- MissingFieldException.cs
- DependencyObjectPropertyDescriptor.cs
- WindowsTitleBar.cs
- WebPartAddingEventArgs.cs
- QilDataSource.cs
- VarRefManager.cs
- TemplateBindingExpressionConverter.cs
- EntityCommandExecutionException.cs
- Point3DAnimation.cs
- RegexCompiler.cs
- DocumentSequence.cs
- XsltInput.cs
- DataContractSerializerOperationBehavior.cs
- DifferencingCollection.cs
- XmlDictionary.cs
- SystemIPAddressInformation.cs
- StrokeRenderer.cs