/// <include file='doc\DataGridGeneralPage.uex' path='docs/doc[@for="DataGridGeneralPage.LoadDataSourceFields"]/*' /> /// <devdoc> /// </devdoc> private void LoadDataSourceFields() { EnterLoadingMode(); dataKeyFieldCombo.SelectedIndex = -1; dataKeyFieldCombo.Items.Clear(); dataKeyFieldCombo.EnsureNotSetItem(); if (currentDataSource != null) { PropertyDescriptorCollection fields = currentDataSource.Fields; if (fields != null) { IEnumerator fieldEnum = fields.GetEnumerator(); while (fieldEnum.MoveNext()) { PropertyDescriptor fieldDesc = (PropertyDescriptor)fieldEnum.Current; if (BaseDataList.IsBindableType(fieldDesc.PropertyType)) { dataKeyFieldCombo.AddItem(fieldDesc.Name); } } } } ExitLoadingMode(); }
/// <include file='doc\DataGridGeneralPage.uex' path='docs/doc[@for="DataGridGeneralPage.LoadDataSourceItems"]/*' /> /// <devdoc> /// Loads the list of available IEnumerable components /// </devdoc> private void LoadDataSourceItems() { dataSourceCombo.EnsureNotSetItem(); ISite thisSite = GetSelectedComponent().Site; if (thisSite != null) { IContainer container = (IContainer)thisSite.GetService(typeof(IContainer)); if (container != null) { ComponentCollection allComponents = container.Components; if (allComponents != null) { foreach (IComponent comp in (IEnumerable)allComponents) { if ((comp is IEnumerable) || (comp is IListSource)) { // must have a valid site and a name ISite componentSite = comp.Site; if ((componentSite == null) || (componentSite.Name == null) || (componentSite.Name.Length == 0)) { continue; } DataSourceItem dsItem; if (comp is IListSource) { // an IListSource IListSource listSource = (IListSource)comp; dsItem = new ListSourceDataSourceItem(componentSite.Name, listSource); } else { // found an IEnumerable IEnumerable dataSource = (IEnumerable)comp; dsItem = new DataSourceItem(componentSite.Name, dataSource); } dataSourceCombo.AddItem(dsItem); } } } } } }
/// <include file='doc\DataGridGeneralPage.uex' path='docs/doc[@for="DataGridGeneralPage.LoadDataMembers"]/*' /> /// <devdoc> /// </devdoc> private void LoadDataMembers() { EnterLoadingMode(); dataMemberCombo.SelectedIndex = -1; dataMemberCombo.Items.Clear(); dataMemberCombo.EnsureNotSetItem(); if ((currentDataSource != null) && (currentDataSource is ListSourceDataSourceItem)) { string[] dataMembers = ((ListSourceDataSourceItem)currentDataSource).DataMembers; for (int i = 0; i < dataMembers.Length; i++) { dataMemberCombo.AddItem(dataMembers[i]); } } ExitLoadingMode(); }