Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / FormatStringEditor.cs / 1 / FormatStringEditor.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.FormatStringEditor..ctor()")]
namespace System.Windows.Forms.Design {
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
///
///
/// Provides an editor to edit advanced binding objects.
///
internal class FormatStringEditor : UITypeEditor {
private FormatStringDialog formatStringDialog;
///
///
/// Edits the specified value using the specified provider
/// within the specified context.
///
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) {
if (provider != null) {
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null) {
DataGridViewCellStyle dgvCellStyle = context.Instance as DataGridViewCellStyle;
ListControl listControl = context.Instance as ListControl;
Debug.Assert(listControl != null || dgvCellStyle != null, "this editor is used for the DataGridViewCellStyle::Format and the ListControl::FormatString properties");
if (formatStringDialog == null) {
formatStringDialog = new FormatStringDialog(context);
}
if (listControl != null) {
formatStringDialog.ListControl = listControl;
} else {
formatStringDialog.DataGridViewCellStyle = dgvCellStyle;
}
IComponentChangeService changeSvc = (IComponentChangeService)provider.GetService(typeof(IComponentChangeService));
if (changeSvc != null) {
if (dgvCellStyle != null) {
changeSvc.OnComponentChanging(dgvCellStyle, TypeDescriptor.GetProperties(dgvCellStyle)["Format"]);
changeSvc.OnComponentChanging(dgvCellStyle, TypeDescriptor.GetProperties(dgvCellStyle)["NullValue"]);
changeSvc.OnComponentChanging(dgvCellStyle, TypeDescriptor.GetProperties(dgvCellStyle)["FormatProvider"]);
} else {
changeSvc.OnComponentChanging(listControl, TypeDescriptor.GetProperties(listControl)["FormatString"]);
changeSvc.OnComponentChanging(listControl, TypeDescriptor.GetProperties(listControl)["FormatInfo"]);
}
}
edSvc.ShowDialog(formatStringDialog);
formatStringDialog.End();
if (formatStringDialog.Dirty) {
// since the bindings may have changed, the properties listed in the properties window
// need to be refreshed
TypeDescriptor.Refresh(context.Instance);
if (changeSvc != null) {
if (dgvCellStyle != null) {
changeSvc.OnComponentChanged(dgvCellStyle, TypeDescriptor.GetProperties(dgvCellStyle)["Format"], null, null);
changeSvc.OnComponentChanged(dgvCellStyle, TypeDescriptor.GetProperties(dgvCellStyle)["NullValue"], null, null);
changeSvc.OnComponentChanged(dgvCellStyle, TypeDescriptor.GetProperties(dgvCellStyle)["FormatProvider"], null, null);
} else {
changeSvc.OnComponentChanged(listControl, TypeDescriptor.GetProperties(listControl)["FormatString"], null, null);
changeSvc.OnComponentChanged(listControl, TypeDescriptor.GetProperties(listControl)["FormatInfo"], null, null);
}
}
}
}
}
return value;
}
///
///
/// Gets the edit style from the current context.
///
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) {
return UITypeEditorEditStyle.Modal;
}
}
}
// 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
- OdbcDataReader.cs
- EmissiveMaterial.cs
- DesignerCategoryAttribute.cs
- DbExpressionVisitor.cs
- SecurityKeyIdentifierClause.cs
- TargetFrameworkUtil.cs
- WebPartCancelEventArgs.cs
- DodSequenceMerge.cs
- CompoundFileIOPermission.cs
- VerticalAlignConverter.cs
- ListSourceHelper.cs
- ControlValuePropertyAttribute.cs
- ThreadNeutralSemaphore.cs
- DeviceContext.cs
- ObjectStorage.cs
- SearchForVirtualItemEventArgs.cs
- PageOutputColor.cs
- GenericUriParser.cs
- EditorBrowsableAttribute.cs
- PrivilegedConfigurationManager.cs
- DataGridViewRowHeaderCell.cs
- Tile.cs
- ValueSerializerAttribute.cs
- DocumentReference.cs
- HostedHttpTransportManager.cs
- Vector3DAnimation.cs
- TreeNodeBindingCollection.cs
- SystemColors.cs
- PrintDocument.cs
- HtmlInputSubmit.cs
- SystemException.cs
- DataGridViewTextBoxColumn.cs
- FrameworkContentElement.cs
- EndpointConfigContainer.cs
- DataSet.cs
- IdnMapping.cs
- _HTTPDateParse.cs
- ErrorFormatterPage.cs
- CellPartitioner.cs
- TrackingParameters.cs
- BuildProvider.cs
- UnknownBitmapDecoder.cs
- PropertyGroupDescription.cs
- ObjectTypeMapping.cs
- WorkflowPersistenceService.cs
- IPGlobalProperties.cs
- Perspective.cs
- EdmProperty.cs
- RuleInfoComparer.cs
- DeflateStream.cs
- QuestionEventArgs.cs
- MasterPage.cs
- Html32TextWriter.cs
- DataBinder.cs
- Normalization.cs
- Debug.cs
- SvcMapFileSerializer.cs
- AutomationPropertyInfo.cs
- UnaryExpression.cs
- WindowsSlider.cs
- SqlTriggerAttribute.cs
- Accessors.cs
- SchemaImporter.cs
- OutputCacheSection.cs
- SchemaNames.cs
- Console.cs
- XmlSchemaAttributeGroup.cs
- Content.cs
- Util.cs
- EntityContainerEntitySet.cs
- UriParserTemplates.cs
- Literal.cs
- RepeaterDesigner.cs
- ZipFileInfoCollection.cs
- CodeAccessPermission.cs
- bidPrivateBase.cs
- OdbcParameterCollection.cs
- TransactionFlowProperty.cs
- XmlTypeMapping.cs
- ViewStateChangedEventArgs.cs
- OleDbReferenceCollection.cs
- GridViewSortEventArgs.cs
- TdsParserStaticMethods.cs
- SqlDataSourceView.cs
- EnvelopeVersion.cs
- DataObject.cs
- WhitespaceRule.cs
- EntityDataSourceValidationException.cs
- RtfControls.cs
- CharacterBuffer.cs
- PkcsUtils.cs
- RtfControlWordInfo.cs
- SendReply.cs
- DataGridAddNewRow.cs
- XmlCompatibilityReader.cs
- DataGridViewControlCollection.cs
- MenuAdapter.cs
- CqlIdentifiers.cs
- CodeStatement.cs
- PasswordTextContainer.cs