private void ViewDataTableResult() { if (_dataTableResult != null) { Try(() => ResizeDataTableImages(_dataTableResult)); Try(() => _gridResult1.SetDataSource(_dataTableResult, _xmlResultFormat)); Try(() => _gridResult2.SetDataSource(_dataTableResult)); Try(() => _gridResult3.DataSource = _dataTableResult.DefaultView); } else if (_dataSetResult != null) { Try(() => _gridResult1.SetDataSource(_dataSetResult.Tables[0], _xmlResultFormat)); Try(() => _gridResult2.SetDataSource(_dataSetResult.Tables[0])); Try(() => _gridResult3.DataSource = _dataSetResult); } else { _gridResult1.ClearDataSource(); _gridResult2.DataSource = null; _gridResult3.DataSource = null; } }
private static WmtsLocationControl ShowFullyConfiguredWmtsLocationControl(Form form, IWmtsCapabilityFactory wmtsCapabilityFactory) { WmtsLocationControl control = ShowValidWmtsLocationControl(form, wmtsCapabilityFactory); var capabilities = new[] { new WmtsCapability("-", "image/png", "-", "-"), new WmtsCapability("brtachtergrondkaart(EPSG:28992)", "image/png8", "brtachtergrondkaart", "EPSG:28992") }; DataGridViewControl dataGridViewControl = form.Controls.Find("dataGridViewControl", true).OfType<DataGridViewControl>().First(); dataGridViewControl.SetDataSource(capabilities); return control; }
public void FormatCellWithColumnStateDefinition_WithArguments_FormatsCell( bool isReadOnly, string errorText, CellStyle cellStyle) { // Setup var definition = new DataGridViewColumnStateDefinition { ReadOnly = isReadOnly, ErrorText = errorText, Style = cellStyle }; var mocks = new MockRepository(); var row = mocks.Stub <IHasColumnStateDefinitions>(); row.Stub(r => r.ColumnStateDefinitions).Return(new Dictionary <int, DataGridViewColumnStateDefinition> { { 0, definition } }); mocks.ReplayAll(); using (var form = new Form()) using (var dataGridViewControl = new DataGridViewControl()) { form.Controls.Add(dataGridViewControl); form.Show(); dataGridViewControl.AddTextBoxColumn(null, "Test"); dataGridViewControl.SetDataSource(new[] { row }); // Call dataGridViewControl.FormatCellWithColumnStateDefinition(0, 0); // Assert DataGridViewCell cell = dataGridViewControl.Rows[0].Cells[0]; Assert.AreEqual(isReadOnly, cell.ReadOnly); Assert.AreEqual(errorText, cell.ErrorText); Assert.AreEqual(cellStyle.BackgroundColor, cell.Style.BackColor); Assert.AreEqual(cellStyle.TextColor, cell.Style.ForeColor); mocks.VerifyAll(); } }
/// <summary> /// Updates the data source of the data grid view with the current known failure mechanism section results. /// </summary> private void UpdateDataGridViewDataSource() { DataGridViewControl.EndEdit(); RemoveSectionResultRowEvents(); sectionResultRows = failureMechanismSectionResults .Select(CreateFailureMechanismSectionResultRow) .Where(sr => sr != null) .ToList(); DataGridViewControl.SetDataSource(sectionResultRows); sectionResultRows.ForEachElementDo(row => { row.RowUpdated += RowUpdated; row.RowUpdateDone += RowUpdateDone; }); }
/// <summary> /// Creates a new instance of <see cref="PipingSurfaceLineSelectionDialog"/>. /// </summary> /// <param name="dialogParent">The parent of the dialog.</param> /// <param name="surfaceLines">The collection of <see cref="PipingSurfaceLine"/> to show in the dialog.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> public PipingSurfaceLineSelectionDialog(IWin32Window dialogParent, IEnumerable <PipingSurfaceLine> surfaceLines) : base(dialogParent, RiskeerCommonFormsResources.GenerateScenariosIcon, 370, 550) { if (surfaceLines == null) { throw new ArgumentNullException(nameof(surfaceLines)); } InitializeComponent(); InitializeEventHandlers(); Localize(); SelectedItems = new List <PipingSurfaceLine>(); Text = Resources.PipingSurfaceLineSelectionDialog_Select_SurfaceLines; InitializeDataGridView(); DataGridViewControl.SetDataSource(surfaceLines.Select(sl => new SelectableRow <PipingSurfaceLine>(sl, sl.Name)).ToArray()); SemiProbabilisticCheckBox.Checked = true; }
public void FormatCellWithColumnStateDefinition_RowWithoutColumnStateDefinitions_DoesNotThrow() { // Setup using (var form = new Form()) using (var dataGridViewControl = new DataGridViewControl()) { form.Controls.Add(dataGridViewControl); form.Show(); dataGridViewControl.AddTextBoxColumn(null, "Test"); dataGridViewControl.SetDataSource(new[] { new object() }); // Call void Call() => dataGridViewControl.FormatCellWithColumnStateDefinition(0, 0); // Assert Assert.DoesNotThrow(Call); } }
/// <summary> /// Sets the datasource on the <see cref="DataGridView"/>. /// </summary> protected void SetDataSource(IEnumerable data) { DataGridViewControl.SetDataSource(data); }