Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ComboBoxDesigner.cs / 1 / ComboBoxDesigner.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.ComboBoxDesigner..ctor()")]
namespace System.Windows.Forms.Design {
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms.Design.Behavior;
///
///
///
/// Provides a designer that can design components
/// that extend ComboBox.
///
internal class ComboBoxDesigner : ControlDesigner {
private EventHandler propChanged = null; // Delegate used to dirty the selectionUIItem when needed.
private DesignerActionListCollection _actionLists;
///
///
/// Adds a baseline SnapLine to the list of SnapLines related
/// to this control.
///
public override IList SnapLines {
get {
ArrayList snapLines = base.SnapLines as ArrayList;
//a single text-baseline for the label (and linklabel) control
int baseline = DesignerUtils.GetTextBaseline(Control, System.Drawing.ContentAlignment.TopLeft);
baseline += 3;
snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
return snapLines;
}
}
///
///
/// Disposes of this object.
///
protected override void Dispose(bool disposing) {
if (disposing) {
// Hook up the property change notification so that we can dirty the SelectionUIItem when needed.
if (propChanged != null) {
((ComboBox)Control).StyleChanged -= propChanged;
}
}
base.Dispose(disposing);
}
///
///
/// Called by the host when we're first initialized.
///
public override void Initialize(IComponent component) {
base.Initialize(component);
AutoResizeHandles = true;
// Hook up the property change notification so that we can dirty the SelectionUIItem when needed.
propChanged = new EventHandler(this.OnControlPropertyChanged);
((ComboBox)Control).StyleChanged += propChanged;
}
///
///
/// We override this so we can clear the text field set by controldesigner.
///
public override void InitializeNewComponent(IDictionary defaultValues) {
base.InitializeNewComponent(defaultValues);
// in Whidbey, formattingEnabled is TRUE
((ComboBox) this.Component).FormattingEnabled = true;
PropertyDescriptor textProp = TypeDescriptor.GetProperties(Component)["Text"];
if (textProp != null && textProp.PropertyType == typeof(string) && !textProp.IsReadOnly && textProp.IsBrowsable) {
textProp.SetValue(Component, "");
}
}
///
///
/// For controls, we sync their property changed event so our component can track their location.
///
private void OnControlPropertyChanged(object sender, EventArgs e) {
if (BehaviorService != null) {
BehaviorService.SyncSelection();
}
}
///
///
/// Retrieves a set of rules concerning the movement capabilities of a component.
/// This should be one or more flags from the SelectionRules class. If no designer
/// provides rules for a component, the component will not get any UI services.
///
public override SelectionRules SelectionRules {
get {
SelectionRules rules = base.SelectionRules;
object component = Component;
PropertyDescriptor propStyle = TypeDescriptor.GetProperties(component)["DropDownStyle"];
if (propStyle != null) {
ComboBoxStyle style = (ComboBoxStyle)propStyle.GetValue(component);
// Height is not user-changable for these styles
if (style == ComboBoxStyle.DropDown || style == ComboBoxStyle.DropDownList)
rules &= ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable);
}
return rules;
}
}
public override DesignerActionListCollection ActionLists {
get {
if (_actionLists == null) {
_actionLists = new DesignerActionListCollection();
_actionLists.Add(new ListControlBoundActionList(this));
}
return _actionLists;
}
}
}
}
// 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
- ViewStateException.cs
- NotifyIcon.cs
- InternalCache.cs
- RegexParser.cs
- SynchronizedDisposablePool.cs
- ListenDesigner.cs
- ButtonBaseAutomationPeer.cs
- HttpProfileBase.cs
- SynchronizationLockException.cs
- RepeaterItem.cs
- ScriptModule.cs
- IntSecurity.cs
- SqlRemoveConstantOrderBy.cs
- WizardPanel.cs
- StylusPointPropertyInfo.cs
- QuaternionConverter.cs
- XmlSchemaComplexContentExtension.cs
- ToolStripDropDownButton.cs
- TreeNodeMouseHoverEvent.cs
- Condition.cs
- httpapplicationstate.cs
- GroupItem.cs
- SafeUserTokenHandle.cs
- WrappedIUnknown.cs
- MouseCaptureWithinProperty.cs
- Crc32.cs
- CommunicationException.cs
- DatasetMethodGenerator.cs
- cookiecollection.cs
- PixelShader.cs
- XmlEncoding.cs
- CompilerError.cs
- TextParagraph.cs
- Input.cs
- TypeCacheManager.cs
- WhereQueryOperator.cs
- BindingExpressionUncommonField.cs
- GridViewUpdateEventArgs.cs
- RectangleF.cs
- XamlStyleSerializer.cs
- CharacterShapingProperties.cs
- StylusPointPropertyInfo.cs
- BufferedConnection.cs
- BaseAsyncResult.cs
- XmlSchemaType.cs
- NegotiateStream.cs
- BindingMAnagerBase.cs
- BaseParaClient.cs
- EventPrivateKey.cs
- RepeatInfo.cs
- FacetChecker.cs
- Int64Animation.cs
- TextBoxBase.cs
- NetworkAddressChange.cs
- _ListenerResponseStream.cs
- TrackingLocation.cs
- OledbConnectionStringbuilder.cs
- BamlTreeNode.cs
- wmiprovider.cs
- WhitespaceRuleLookup.cs
- XmlPropertyBag.cs
- Documentation.cs
- DoubleAnimationBase.cs
- PackageRelationshipSelector.cs
- JavascriptCallbackBehaviorAttribute.cs
- PageThemeParser.cs
- ServiceModelSecurityTokenRequirement.cs
- InkPresenter.cs
- GPStream.cs
- ErrorHandler.cs
- GridSplitter.cs
- PropertyEmitter.cs
- PageCache.cs
- ExtendedProtectionPolicy.cs
- FormDesigner.cs
- DynamicPropertyHolder.cs
- GlyphTypeface.cs
- ManagementScope.cs
- PhoneCallDesigner.cs
- GroupBoxAutomationPeer.cs
- Soap12ProtocolReflector.cs
- PropertyEmitterBase.cs
- GenericPrincipal.cs
- ConfigurationStrings.cs
- TabRenderer.cs
- MinMaxParagraphWidth.cs
- DataSourceControl.cs
- GlobalizationSection.cs
- FastEncoder.cs
- TypeViewSchema.cs
- DrawListViewColumnHeaderEventArgs.cs
- WebPartMenu.cs
- XmlEncodedRawTextWriter.cs
- Types.cs
- GlobalEventManager.cs
- SerializationInfoEnumerator.cs
- VirtualDirectoryMapping.cs
- SurrogateSelector.cs
- StatusBarDrawItemEvent.cs
- VersionUtil.cs