Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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.
//
//-----------------------------------------------------------------------------
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
- MessageEventSubscriptionService.cs
- SupportsEventValidationAttribute.cs
- TypeLoader.cs
- ClientSettingsStore.cs
- ObjectManager.cs
- PasswordTextContainer.cs
- TypeReference.cs
- Stackframe.cs
- DbModificationCommandTree.cs
- SelectionListDesigner.cs
- StringOutput.cs
- Region.cs
- BitmapData.cs
- WorkflowApplicationCompletedException.cs
- SecurityCriticalDataForSet.cs
- Vector3DCollectionValueSerializer.cs
- ControlBindingsConverter.cs
- DataGridRowHeaderAutomationPeer.cs
- ListViewDeletedEventArgs.cs
- StateBag.cs
- SR.cs
- ISFClipboardData.cs
- ExtentCqlBlock.cs
- AuthenticateEventArgs.cs
- TreeViewHitTestInfo.cs
- BaseResourcesBuildProvider.cs
- Registry.cs
- SettingsBindableAttribute.cs
- DragEventArgs.cs
- Point3DCollectionConverter.cs
- HttpRuntime.cs
- HttpRequestWrapper.cs
- LinqDataSourceDeleteEventArgs.cs
- XmlSchemaGroupRef.cs
- SafeNativeMethodsOther.cs
- Column.cs
- SHA1Managed.cs
- MDIClient.cs
- ComponentManagerBroker.cs
- ConvertEvent.cs
- Command.cs
- CustomAttribute.cs
- DataTablePropertyDescriptor.cs
- ScrollEvent.cs
- DiscoveryClientDuplexChannel.cs
- LayoutEditorPart.cs
- XmlParser.cs
- EntityException.cs
- Track.cs
- ResourceDisplayNameAttribute.cs
- AllowedAudienceUriElementCollection.cs
- securitycriticaldata.cs
- GeneralTransform3D.cs
- SqlCharStream.cs
- ScrollViewerAutomationPeer.cs
- HttpRawResponse.cs
- PerfCounters.cs
- DataGridPageChangedEventArgs.cs
- TriggerBase.cs
- Property.cs
- ConnectionStringSettings.cs
- MessageSecurityOverHttp.cs
- TextRangeEditTables.cs
- XmlChoiceIdentifierAttribute.cs
- SettingsAttributes.cs
- WebPartDisplayModeEventArgs.cs
- ICollection.cs
- XPathParser.cs
- FontWeight.cs
- IsolatedStorageFile.cs
- ObjectDataSourceWizardForm.cs
- Transform3DGroup.cs
- SystemException.cs
- XmlWellformedWriter.cs
- MachineKeySection.cs
- AppearanceEditorPart.cs
- ToolStripRendererSwitcher.cs
- Regex.cs
- Rijndael.cs
- FusionWrap.cs
- AuthenticationModuleElement.cs
- LoginName.cs
- TdsParserSessionPool.cs
- AuthenticationConfig.cs
- RightNameExpirationInfoPair.cs
- RemotingServices.cs
- TypeGenericEnumerableViewSchema.cs
- ArrayList.cs
- DecimalMinMaxAggregationOperator.cs
- ThemeableAttribute.cs
- CodeCatchClauseCollection.cs
- TextFindEngine.cs
- AuthorizationSection.cs
- DataGridRow.cs
- ComPlusInstanceContextInitializer.cs
- UnicodeEncoding.cs
- ServiceChannelFactory.cs
- GAC.cs
- PageCodeDomTreeGenerator.cs
- RelativeSource.cs