Code:
/ FX-1434 / FX-1434 / 1.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
- ISO2022Encoding.cs
- MultipartIdentifier.cs
- MaterializeFromAtom.cs
- KeyValuePairs.cs
- DataDesignUtil.cs
- HttpSocketManager.cs
- SeekableReadStream.cs
- TypeUnloadedException.cs
- GraphicsPath.cs
- Quaternion.cs
- NullableConverter.cs
- Visual.cs
- ComponentEditorPage.cs
- Bezier.cs
- BitmapMetadata.cs
- UIntPtr.cs
- WmlCalendarAdapter.cs
- GenericTypeParameterConverter.cs
- SoapSchemaExporter.cs
- TypeNameConverter.cs
- MediaTimeline.cs
- BindingListCollectionView.cs
- LocalIdKeyIdentifierClause.cs
- ResourceCategoryAttribute.cs
- DetailsViewDesigner.cs
- CalendarDayButton.cs
- SplitterEvent.cs
- RoutedEventConverter.cs
- TextRangeAdaptor.cs
- WinFormsSpinner.cs
- ScrollProviderWrapper.cs
- Type.cs
- ToolStripTextBox.cs
- XPathNavigatorReader.cs
- NativeMethods.cs
- ExternalException.cs
- OdbcCommandBuilder.cs
- ComponentChangedEvent.cs
- X509CertificateStore.cs
- MSAANativeProvider.cs
- XmlElementAttribute.cs
- AssociationType.cs
- DesignerTransactionCloseEvent.cs
- InvokeHandlers.cs
- ScrollBar.cs
- AdjustableArrowCap.cs
- ApplicationFileParser.cs
- SocketCache.cs
- SatelliteContractVersionAttribute.cs
- _ProxyChain.cs
- NamedElement.cs
- FontConverter.cs
- UIPropertyMetadata.cs
- XmlILAnnotation.cs
- Pens.cs
- SqlBuilder.cs
- AppSettingsSection.cs
- VariableModifiersHelper.cs
- WebPartAuthorizationEventArgs.cs
- _NtlmClient.cs
- Quad.cs
- CodeValidator.cs
- TimeStampChecker.cs
- LinqDataSource.cs
- XmlAnyElementAttributes.cs
- SchemaTypeEmitter.cs
- ClientBuildManager.cs
- HatchBrush.cs
- GenericsInstances.cs
- CacheSection.cs
- XmlSubtreeReader.cs
- ClientRolePrincipal.cs
- ByeMessage11.cs
- WebPartRestoreVerb.cs
- ToolStripControlHost.cs
- WindowsContainer.cs
- ListBindingHelper.cs
- AssociationProvider.cs
- TdsParserHelperClasses.cs
- GlyphInfoList.cs
- Pair.cs
- GeneralTransform.cs
- Attribute.cs
- IncomingWebResponseContext.cs
- ButtonBaseAutomationPeer.cs
- DataTableMapping.cs
- RelatedView.cs
- InkCollectionBehavior.cs
- TextViewBase.cs
- ContextMenuStrip.cs
- CustomErrorsSection.cs
- util.cs
- DataGridViewImageCell.cs
- BitmapEditor.cs
- MbpInfo.cs
- AncillaryOps.cs
- ParenthesizePropertyNameAttribute.cs
- TextChange.cs
- AnchoredBlock.cs
- BaseWebProxyFinder.cs