/// <include file='doc\DataGridGeneralPage.uex' path='docs/doc[@for="DataGridGeneralPage.LoadComponent"]/*' />
        /// <devdoc>
        ///   Loads the component into the page.
        /// </devdoc>
        protected override void LoadComponent()
        {
            InitPage();

            DataGrid dataGrid = (DataGrid)GetBaseControl();

            LoadDataSourceItems();

            showHeaderCheck.Checked   = dataGrid.ShowHeader;
            showFooterCheck.Checked   = dataGrid.ShowFooter;
            allowSortingCheck.Checked = dataGrid.AllowSorting;

            if (dataSourceCombo.Items.Count > 0)
            {
                DataGridDesigner dataGridDesigner = (DataGridDesigner)GetBaseDesigner();
                string           dataSourceValue  = dataGridDesigner.DataSource;

                if (dataSourceValue != null)
                {
                    int dataSourcesAvailable = dataSourceCombo.Items.Count;
                    for (int j = 1; j < dataSourcesAvailable; j++)
                    {
                        DataSourceItem dataSourceItem =
                            (DataSourceItem)dataSourceCombo.Items[j];

                        if (String.Compare(dataSourceItem.Name, dataSourceValue, true, CultureInfo.InvariantCulture) == 0)
                        {
                            dataSourceCombo.SelectedIndex = j;
                            currentDataSource             = dataSourceItem;
                            LoadDataMembers();

                            if (currentDataSource is ListSourceDataSourceItem)
                            {
                                string dataMember = dataGridDesigner.DataMember;
                                dataMemberCombo.SelectedIndex = dataMemberCombo.FindStringExact(dataMember);

                                if (dataMemberCombo.IsSet())
                                {
                                    ((ListSourceDataSourceItem)currentDataSource).CurrentDataMember = dataMember;
                                }
                            }

                            LoadDataSourceFields();

                            break;
                        }
                    }
                }
            }

            string dataKeyField = dataGrid.DataKeyField;

            if (dataKeyField.Length != 0)
            {
                int fieldIndex = dataKeyFieldCombo.FindStringExact(dataKeyField);
                dataKeyFieldCombo.SelectedIndex = fieldIndex;
            }

            if (dataGrid.AutoGenerateColumns)
            {
                columnInfoLabel.Text = SR.GetString(SR.DGGen_AutoColumnInfo);
            }
            else
            {
                columnInfoLabel.Text = SR.GetString(SR.DGGen_CustomColumnInfo);
            }

            UpdateEnabledVisibleState();
        }
예제 #2
0
        /// <include file='doc\DataListGeneralPage.uex' path='docs/doc[@for="DataListGeneralPage.LoadComponent"]/*' />
        /// <devdoc>
        ///   Loads the component into the page.
        /// </devdoc>
        protected override void LoadComponent()
        {
            InitPage();

            DataList dataList = (DataList)GetBaseControl();

            LoadDataSourceItems();

            showHeaderCheck.Checked = dataList.ShowHeader;
            showFooterCheck.Checked = dataList.ShowFooter;

            repeatColumnsEdit.Text = (dataList.RepeatColumns).ToString();

            switch (dataList.RepeatDirection)
            {
            case RepeatDirection.Horizontal:
                repeatDirectionCombo.SelectedIndex = IDX_DIR_HORIZONTAL;
                break;

            case RepeatDirection.Vertical:
                repeatDirectionCombo.SelectedIndex = IDX_DIR_VERTICAL;
                break;
            }

            switch (dataList.RepeatLayout)
            {
            case RepeatLayout.Table:
                repeatLayoutCombo.SelectedIndex = IDX_MODE_TABLE;
                break;

            case RepeatLayout.Flow:
                repeatLayoutCombo.SelectedIndex = IDX_MODE_FLOW;
                break;
            }

            extractRowsCheck.Checked = dataList.ExtractTemplateRows;

            if (dataSourceCombo.Items.Count > 0)
            {
                DataListDesigner dataListDesigner = (DataListDesigner)GetBaseDesigner();
                string           dataSourceValue  = dataListDesigner.DataSource;

                if (dataSourceValue != null)
                {
                    int dataSourcesAvailable = dataSourceCombo.Items.Count;
                    for (int j = 1; j < dataSourcesAvailable; j++)
                    {
                        DataSourceItem dataSourceItem =
                            (DataSourceItem)dataSourceCombo.Items[j];

                        if (String.Compare(dataSourceItem.Name, dataSourceValue, true, CultureInfo.InvariantCulture) == 0)
                        {
                            dataSourceCombo.SelectedIndex = j;
                            currentDataSource             = dataSourceItem;
                            LoadDataMembers();

                            if (currentDataSource is ListSourceDataSourceItem)
                            {
                                string dataMember = dataListDesigner.DataMember;
                                dataMemberCombo.SelectedIndex = dataMemberCombo.FindStringExact(dataMember);

                                if (dataMemberCombo.IsSet())
                                {
                                    ((ListSourceDataSourceItem)currentDataSource).CurrentDataMember = dataMember;
                                }
                            }

                            LoadDataSourceFields();

                            break;
                        }
                    }
                }
            }

            string dataKeyField = dataList.DataKeyField;

            if (dataKeyField.Length != 0)
            {
                int fieldIndex = dataKeyFieldCombo.FindStringExact(dataKeyField);
                dataKeyFieldCombo.SelectedIndex = fieldIndex;
            }

            UpdateEnabledVisibleState();
        }