Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / DataGridViewComboBoxColumnDesigner.cs / 1 / DataGridViewComboBoxColumnDesigner.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Design { using System.Design; using System.ComponentModel; using System.Diagnostics; using System; using System.Collections; using System.Windows.Forms; using System.Data; using System.ComponentModel.Design; using System.Drawing; using Microsoft.Win32; using System.Windows.Forms.ComponentModel; ////// /// internal class DataGridViewComboBoxColumnDesigner : DataGridViewColumnDesigner { static BindingContext bc; private string ValueMember { get { DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) this.Component; return col.ValueMember; } set { DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) this.Component; if (col.DataSource == null) { return; } if (ValidDataMember(col.DataSource, value)) { col.ValueMember = value; } } } private string DisplayMember { get { DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) this.Component; return col.DisplayMember; } set { DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) this.Component; if (col.DataSource == null) { return; } if (ValidDataMember(col.DataSource, value)) { col.DisplayMember = value; } } } private bool ShouldSerializeDisplayMember() { DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) this.Component; return !String.IsNullOrEmpty(col.DisplayMember); } private bool ShouldSerializeValueMember() { DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) this.Component; return !String.IsNullOrEmpty(col.ValueMember); } private static bool ValidDataMember(object dataSource, string dataMember) { if (String.IsNullOrEmpty(dataMember)) { // a null string is a valid value return true; } if (bc == null) { bc = new BindingContext(); } // // scrub the hashTable inside the BindingContext every time we access this method. // int count = ((ICollection) bc).Count; BindingMemberInfo bmi = new BindingMemberInfo(dataMember); PropertyDescriptorCollection props = null; BindingManagerBase bmb; try { bmb = bc[dataSource, bmi.BindingPath]; } catch (System.ArgumentException) { return false; } if (bmb == null) { return false; } props = bmb.GetItemProperties(); if (props == null) { return false; } if (props[bmi.BindingField] == null) { return false; } return true; } protected override void PreFilterProperties(IDictionary properties) { base.PreFilterProperties(properties); PropertyDescriptor prop = (PropertyDescriptor) properties["ValueMember"]; if (prop != null) { properties["ValueMember"] = TypeDescriptor.CreateProperty(typeof(DataGridViewComboBoxColumnDesigner), prop, new Attribute[0]); } prop = (PropertyDescriptor) properties["DisplayMember"]; if (prop != null) { properties["DisplayMember"] = TypeDescriptor.CreateProperty(typeof(DataGridViewComboBoxColumnDesigner), prop, new Attribute[0]); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.Provides a base designer for data grid view columns. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StateMachineSubscription.cs
- ListViewInsertedEventArgs.cs
- PenThreadPool.cs
- SafeRightsManagementEnvironmentHandle.cs
- DataServiceQuery.cs
- DeferredReference.cs
- BitArray.cs
- MsmqPoisonMessageException.cs
- CurrentChangedEventManager.cs
- ScriptServiceAttribute.cs
- MultilineStringConverter.cs
- WebPartConnectionCollection.cs
- assertwrapper.cs
- CryptoApi.cs
- AssemblyResourceLoader.cs
- Image.cs
- InstanceKeyCollisionException.cs
- ExceptionRoutedEventArgs.cs
- StreamMarshaler.cs
- Variant.cs
- WebPartAddingEventArgs.cs
- DocumentGridContextMenu.cs
- _SSPISessionCache.cs
- HostingEnvironmentException.cs
- XmlObjectSerializerContext.cs
- UserValidatedEventArgs.cs
- ListItem.cs
- TagElement.cs
- ManipulationPivot.cs
- Stroke2.cs
- TTSVoice.cs
- ProfileService.cs
- WorkflowRuntimeServiceElement.cs
- JapaneseLunisolarCalendar.cs
- AllMembershipCondition.cs
- IisTraceWebEventProvider.cs
- MarkupObject.cs
- ProgressBarHighlightConverter.cs
- DataSourceListEditor.cs
- RangeValidator.cs
- BufferedMessageWriter.cs
- StrokeSerializer.cs
- NetworkInformationException.cs
- TemplateKeyConverter.cs
- FontUnit.cs
- base64Transforms.cs
- CardSpaceShim.cs
- TextBlock.cs
- WebHttpDispatchOperationSelector.cs
- RequestTimeoutManager.cs
- HandlerWithFactory.cs
- PriorityBinding.cs
- UpdateCommand.cs
- SemaphoreSlim.cs
- PhoneCall.cs
- ControlIdConverter.cs
- _ListenerRequestStream.cs
- SqlUserDefinedTypeAttribute.cs
- SoapDocumentServiceAttribute.cs
- ImageField.cs
- MapPathBasedVirtualPathProvider.cs
- OutputScopeManager.cs
- DialogResultConverter.cs
- FloatMinMaxAggregationOperator.cs
- SiteMembershipCondition.cs
- WS2007FederationHttpBindingCollectionElement.cs
- XslCompiledTransform.cs
- securitycriticaldataformultiplegetandset.cs
- Overlapped.cs
- XmlHierarchicalDataSourceView.cs
- LeafCellTreeNode.cs
- Style.cs
- PhonemeConverter.cs
- TabOrder.cs
- RuleValidation.cs
- MSAANativeProvider.cs
- Metafile.cs
- EmptyStringExpandableObjectConverter.cs
- DataBoundControl.cs
- UIElementPropertyUndoUnit.cs
- RemotingSurrogateSelector.cs
- CodeObjectCreateExpression.cs
- TileModeValidation.cs
- XmlQueryType.cs
- BindingCollection.cs
- StringResourceManager.cs
- BasicViewGenerator.cs
- FontWeightConverter.cs
- PackageDigitalSignatureManager.cs
- XmlLanguage.cs
- FileDialog_Vista_Interop.cs
- EncodingTable.cs
- ConcatQueryOperator.cs
- SystemIPAddressInformation.cs
- ParameterBuilder.cs
- ReferentialConstraint.cs
- FileRegion.cs
- XamlSerializerUtil.cs
- DefaultProxySection.cs
- HtmlToClrEventProxy.cs