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
- SmiMetaData.cs
- SqlDataSourceView.cs
- BaseUriHelper.cs
- SmiXetterAccessMap.cs
- PermissionRequestEvidence.cs
- XmlSchemaAnyAttribute.cs
- SqlDependencyListener.cs
- TextPointer.cs
- HandleInitializationContext.cs
- WrappedIUnknown.cs
- ContentPresenter.cs
- HealthMonitoringSectionHelper.cs
- LinqExpressionNormalizer.cs
- OleDbCommandBuilder.cs
- XmlSchemaNotation.cs
- DBSqlParser.cs
- _AutoWebProxyScriptHelper.cs
- DocumentViewerHelper.cs
- EmptyEnumerable.cs
- StreamReader.cs
- GeometryConverter.cs
- WebPartActionVerb.cs
- WebPartDisplayMode.cs
- GroupedContextMenuStrip.cs
- DbProviderFactoriesConfigurationHandler.cs
- MasterPageCodeDomTreeGenerator.cs
- DocumentGridContextMenu.cs
- BinHexEncoder.cs
- WorkflowItemPresenter.cs
- NavigateUrlConverter.cs
- AxHost.cs
- EntityModelSchemaGenerator.cs
- StateRuntime.cs
- SingleKeyFrameCollection.cs
- ParameterElementCollection.cs
- SqlDataRecord.cs
- PeerInputChannel.cs
- ServiceDescriptions.cs
- OAVariantLib.cs
- ExtenderProviderService.cs
- Translator.cs
- ErrorActivity.cs
- IndexExpression.cs
- TextSelectionProcessor.cs
- ServiceModelPerformanceCounters.cs
- EqualityComparer.cs
- XsltSettings.cs
- SystemWebSectionGroup.cs
- MessageDesigner.cs
- Evaluator.cs
- InstanceLockException.cs
- Animatable.cs
- CachedRequestParams.cs
- DiscreteKeyFrames.cs
- DataRowCollection.cs
- UiaCoreProviderApi.cs
- InteropBitmapSource.cs
- Message.cs
- CustomLineCap.cs
- OleDbError.cs
- TrustManager.cs
- ExtendedProperty.cs
- AutomationElement.cs
- DataServiceExpressionVisitor.cs
- DocumentOrderQuery.cs
- HostVisual.cs
- SweepDirectionValidation.cs
- PackageRelationshipSelector.cs
- SchemaExporter.cs
- RevocationPoint.cs
- ToolboxComponentsCreatedEventArgs.cs
- HttpCacheVaryByContentEncodings.cs
- Rectangle.cs
- CryptoStream.cs
- BamlStream.cs
- ProviderBase.cs
- BamlResourceDeserializer.cs
- BitmapEffectInput.cs
- TimeZone.cs
- StaticFileHandler.cs
- FlowLayout.cs
- NavigatingCancelEventArgs.cs
- DuplexClientBase.cs
- WebServicesDescriptionAttribute.cs
- Point3DAnimation.cs
- WMIGenerator.cs
- PointF.cs
- ListViewAutomationPeer.cs
- SqlInternalConnection.cs
- OdbcTransaction.cs
- FamilyMapCollection.cs
- MenuItem.cs
- ToolstripProfessionalRenderer.cs
- WebAdminConfigurationHelper.cs
- WinCategoryAttribute.cs
- controlskin.cs
- ParseNumbers.cs
- FileUtil.cs
- TreeView.cs
- RegexFCD.cs