/// <include file='doc\DataGridGeneralPage.uex' path='docs/doc[@for="DataGridGeneralPage.SaveComponent"]/*' /> /// <devdoc> /// Saves the component loaded into the page. /// </devdoc> protected override void SaveComponent() { DataGrid dataGrid = (DataGrid)GetBaseControl(); dataGrid.ShowHeader = showHeaderCheck.Checked; dataGrid.ShowFooter = showFooterCheck.Checked; dataGrid.AllowSorting = allowSortingCheck.Checked; string dataKeyField = String.Empty; if (dataKeyFieldCombo.IsSet()) { dataKeyField = (string)dataKeyFieldCombo.SelectedItem; } dataGrid.DataKeyField = dataKeyField; if (dataSourceDirty) { // save the datasource as a binding on the control DataGridDesigner dataGridDesigner = (DataGridDesigner)GetBaseDesigner(); DataBindingCollection dataBindings = dataGridDesigner.DataBindings; if (currentDataSource == null) { dataGridDesigner.DataSource = String.Empty; dataGridDesigner.DataMember = String.Empty; } else { dataGridDesigner.DataSource = currentDataSource.ToString(); if (dataMemberCombo.IsSet()) { dataGridDesigner.DataMember = (string)dataMemberCombo.SelectedItem; } else { dataGridDesigner.DataMember = String.Empty; } } dataGridDesigner.OnDataSourceChanged(); } }
public DataSourceGridViewRow(DataSourceItem dataSourceItem, bool displayOnGraph) { this.dsi = dataSourceItem; var displayOnGraphCell = new DataGridViewCheckBoxCell { Value = displayOnGraph }; var datasourceCell = new DataGridViewTextBoxCell { Value = dsi.ToString() }; var typeCell = new DataGridViewTextBoxCell { Value = dsi.DataType.ToStringI18N() }; var colourCell = new DataGridViewTextBoxCell { Value = dsi.Color }; Cells.AddRange(displayOnGraphCell, datasourceCell, typeCell, colourCell); }
/// <include file='doc\DataListGeneralPage.uex' path='docs/doc[@for="DataListGeneralPage.SaveComponent"]/*' /> /// <devdoc> /// Saves the component loaded into the page. /// </devdoc> protected override void SaveComponent() { DataList dataList = (DataList)GetBaseControl(); dataList.ShowHeader = showHeaderCheck.Checked; dataList.ShowFooter = showFooterCheck.Checked; try { int repeatColumns = 1; string repeatColumnsValue = repeatColumnsEdit.Text.Trim(); if (repeatColumnsValue.Length != 0) { repeatColumns = Int32.Parse(repeatColumnsValue, CultureInfo.InvariantCulture); } dataList.RepeatColumns = repeatColumns; } catch (Exception) { repeatColumnsEdit.Text = (dataList.RepeatColumns).ToString(); } switch (repeatDirectionCombo.SelectedIndex) { case IDX_DIR_HORIZONTAL: dataList.RepeatDirection = RepeatDirection.Horizontal; break; case IDX_DIR_VERTICAL: dataList.RepeatDirection = RepeatDirection.Vertical; break; } switch (repeatLayoutCombo.SelectedIndex) { case IDX_MODE_TABLE: dataList.RepeatLayout = RepeatLayout.Table; break; case IDX_MODE_FLOW: dataList.RepeatLayout = RepeatLayout.Flow; break; } dataList.ExtractTemplateRows = extractRowsCheck.Checked; string dataKeyField = String.Empty; if (dataKeyFieldCombo.IsSet()) { dataKeyField = (string)dataKeyFieldCombo.SelectedItem; } dataList.DataKeyField = dataKeyField; if (dataSourceDirty) { DataListDesigner dataListDesigner = (DataListDesigner)GetBaseDesigner(); // save the datasource as a binding on the control DataBindingCollection dataBindings = dataListDesigner.DataBindings; if (currentDataSource == null) { dataListDesigner.DataSource = String.Empty; dataListDesigner.DataMember = String.Empty; } else { dataListDesigner.DataSource = currentDataSource.ToString(); if (dataMemberCombo.IsSet()) { dataListDesigner.DataMember = (string)dataMemberCombo.SelectedItem; } else { dataListDesigner.DataMember = String.Empty; } } dataListDesigner.OnDataSourceChanged(); } }