private void baseColumnCreator(CustomDataGridView <UMD> table, ItemListFormBaseManager <UMD> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <UMD> builder; // Custom cell styles DataGridViewCellStyle monospaceTextCellStyle = table.DefaultCellStyle.Clone(); monospaceTextCellStyle.Font = new Font(FontFamily.GenericMonospace, 9); // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: static text builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Static text"); builder.Width(200); builder.UpdaterMethod((umd, cell) => { cell.Value = umd.StaticText; }); builder.AddChangeEvent(nameof(UMD.StaticText)); // Column: use static text builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.CheckBox); builder.Header("Static"); builder.Width(50); builder.UpdaterMethod((umd, cell) => { cell.Value = umd.UseStaticText; }); builder.CellContentClickHandlerMethod((umd, cell, e) => { umd.UseStaticText = !(bool)cell.Value; }); builder.AddChangeEvent(nameof(UMD.UseStaticText)); // Column: current text builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Current text"); builder.Width(200); builder.CellStyle(monospaceTextCellStyle); builder.UpdaterMethod((umd, cell) => { cell.Value = umd.CurrentText; }); builder.AddChangeEvent(nameof(UMD.CurrentText)); // Columns: tallies for (int i = 0; i < MAX_TALLIES; i++) { builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header(string.Format("T{0}", i + 1)); builder.Width(30); builder.UpdaterMethod((umd, cell) => { cell.Style.BackColor = ((umd.Type.TallyCount > i) && umd.TallyStates[i]) ? umd.TallyColors[i] : Color.LightGray; }); if (i == MAX_TALLIES - 1) { builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); } builder.AddChangeEvent(nameof(UMD.TallyStates)); } // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void baseColumnCreator(CustomDataGridView <Tsl50Screen> table, ItemListFormBaseManager <Tsl50Screen> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <Tsl50Screen> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: state image builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("IP:port"); builder.Width(100); builder.UpdaterMethod((tsl50screen, cell) => { cell.Value = $"{tsl50screen.IpAddress}:{tsl50screen.Port}"; }); builder.AddChangeEvent(nameof(Tsl50Screen.IpAddress)); // Column: state label builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Index"); builder.Width(60); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((tsl50screen, cell) => { cell.Value = tsl50screen.Index; }); builder.AddChangeEvent(nameof(Tsl50Screen.Index)); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void TabPageControlsSetDataGridView() { for (int tabPageIndex = 0; tabPageIndex < tcSorters.TabCount; tabPageIndex++) { try { CustomDataGridView dataGridView = GetMainDataGridViewFromTabPage(tcSorters.TabPages[tabPageIndex]); if (dataGridView != null) { tcSorters.TabPages[tabPageIndex].Controls.Remove(dataGridView); } } catch (InvalidOperationException exception) // more than one CustomDataGrid were found { _logger.Error(exception.Message); // remove all CustomDataGridView for (int i = 0; i < tcSorters.TabPages[tabPageIndex].Controls.Count; i++) { if (tcSorters.TabPages[tabPageIndex].Controls[i].Name == Properties.Settings.Default.CustomDataGridViewName) { tcSorters.TabPages[tabPageIndex].Controls.Remove(tcSorters.TabPages[tabPageIndex].Controls[i]); } } } tcSorters.TabPages[tabPageIndex].Controls.Add(DataGridViewInitialization()); } }
private void initNextHopTable(ref DataGridView originalTable, ref CustomDataGridView <FibTreeLabel> customMember, Panel container, FibTree fibTree) { customMember = CreateTable <FibTreeLabel>(ref originalTable, container); CustomDataGridViewColumnDescriptorBuilder <FibTreeLabel> builder; // Column: prefix, IP format builder = new CustomDataGridViewColumnDescriptorBuilder <FibTreeLabel>(customMember); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Label"); builder.Width(60); builder.UpdaterMethod((entry, cell) => { cell.Value = entry.Text; }); builder.AddChangeEvent(nameof(FibEntry.IpForm)); builder.BuildAndAdd(); // Column: next hop builder = new CustomDataGridViewColumnDescriptorBuilder <FibTreeLabel>(customMember); builder.Type(DataGridViewColumnType.TextBox); builder.Header("IP address"); builder.Width(120); builder.UpdaterMethod((entry, cell) => { cell.Value = entry.NextHop; }); builder.AddChangeEvent(nameof(FibEntry.NextHop)); builder.BuildAndAdd(); // Bind database customMember.BoundCollection = fibTree.Labels; }
public static void TasksToDataGridView(List <Task> lists, DataGridView dgv) { dgv.DataSource = null; dgv.Rows.Clear(); CustomDataGridView.StartupDesign(dgv); for (int i = 0; i < lists.Count; i++) { int n = dgv.Rows.Add(); dgv.Rows[n].Cells[0].Value = lists[i].Id; dgv.Rows[n].Cells[1].Value = lists[i].DateTime; dgv.Rows[n].Cells[2].Value = lists[i].TimeSpan; dgv.Rows[n].Cells[3].Value = lists[i].Description; if (lists[i].IdPriority.ToString() == ((int)PriorityModel.HIGH).ToString()) { dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Red; } else if (lists[i].IdPriority.ToString() == ((int)PriorityModel.MEDIUM).ToString()) { dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Orange; } else { dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Blue; } } }
private void baseColumnCreator(CustomDataGridView <MacroPanel> table, ItemListFormBaseManager <MacroPanel> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <MacroPanel> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: element count builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Elements"); builder.Width(70); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((macroPanel, cell) => { cell.Value = macroPanel.Elements.Count; }); // TODO: builder.AddChangeEvent(nameof(MacroPanel.Elements)); // Column: open button builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.Button); builder.Header("Open"); builder.Width(70); builder.ButtonText("Open"); builder.CellContentClickHandlerMethod((macroPanel, cell, e) => { var window = new MacroPanelForm(macroPanel); window.ShowAsChild(); }); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void initializeTable() { table = CreateTable <Labelset>(); CustomDataGridViewColumnDescriptorBuilder <Labelset> builder; // Column: ID builder = GetColumnDescriptorBuilderForTable <Labelset>(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("ID"); builder.Width(30); builder.UpdaterMethod((router, cell) => { cell.Value = string.Format("#{0}", router.ID); }); builder.AddChangeEvent(nameof(Router.ID)); builder.BuildAndAdd(); // Column: name builder = GetColumnDescriptorBuilderForTable <Labelset>(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Name"); builder.Width(150); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.CellStyle(BOLD_TEXT_CELL_STYLE); builder.UpdaterMethod((router, cell) => { cell.Value = router.Name; }); builder.AddChangeEvent(nameof(Router.Name)); builder.BuildAndAdd(); // Column: edit button builder = GetColumnDescriptorBuilderForTable <Labelset>(); builder.Type(DataGridViewColumnType.Button); builder.Header("Edit"); builder.Width(70); builder.ButtonText("Edit"); builder.CellContentClickHandlerMethod((labelset, cell, e) => { var editWindow = new LabelsetEditorForm(labelset); editWindow?.ShowAsChild(); }); builder.BuildAndAdd(); // Column: delete button builder = GetColumnDescriptorBuilderForTable <Labelset>(); builder.Type(DataGridViewColumnType.Button); builder.Header("Delete"); builder.Width(70); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.ButtonText("Delete"); builder.CellContentClickHandlerMethod((labelset, cell, e) => { string msgBoxText = string.Format("Do you really want to delete this labelset?\n(#{0}) {1}", labelset.ID, labelset.Name); var confirm = MessageBox.Show(msgBoxText, "Delete confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm == DialogResult.Yes) { LabelsetDatabase.Instance.Remove(labelset); } }); builder.BuildAndAdd(); // Bind database table.BoundCollection = LabelsetDatabase.Instance; }
private void btnSelNone_Click(object sender, EventArgs e) { CustomDataGridView view = this.GridView; if (view != null) { view.SelectNone(); } }
private void baseColumnCreator(CustomDataGridView <Labelset> table, ItemListFormBaseManager <Labelset> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void btnInvert_Click(object sender, EventArgs e) { CustomDataGridView view = this.GridView; if (view != null) { view.Invert(); } }
private void CustomDataGridView_SelectionChanged(object sender, EventArgs e) { CustomDataGridView dataGridView = (CustomDataGridView)sender; foreach (DataGridViewTextBoxCell cell in dataGridView.SelectedCells) { cell.Selected = false; } }
private void baseColumnCreator(CustomDataGridView <CrosspointStore> table, ItemListFormBaseManager <CrosspointStore> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <CrosspointStore> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: current output builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Current output"); builder.Width(150); builder.UpdaterMethod((crosspointStore, cell) => { if (crosspointStore.StoredOutput == null) { cell.Value = "-"; return; } cell.Value = string.Format("(#{0}) {1} / (#{2}) {3}", crosspointStore.StoredOutput?.Router?.ID, crosspointStore.StoredOutput?.Router?.Name, crosspointStore.StoredOutput?.Index, crosspointStore.StoredOutput?.Name); }); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredOutput), nameof(RouterOutput.Router), nameof(Router.ID)); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredOutput), nameof(RouterOutput.Router), nameof(Router.Name)); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredOutput), nameof(RouterOutput.Index)); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredOutput), nameof(RouterOutput.Name)); // Column: current input builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Current input"); builder.Width(150); builder.UpdaterMethod((crosspointStore, cell) => { if (crosspointStore.StoredInput == null) { cell.Value = "-"; return; } cell.Value = string.Format("(#{0}) {1} / (#{2}) {3}", crosspointStore.StoredInput?.Router?.ID, crosspointStore.StoredInput?.Router?.Name, crosspointStore.StoredInput?.Index, crosspointStore.StoredInput?.Name); bool invalidCrosspoint = (crosspointStore.StoredInput?.Router != null) && (crosspointStore.StoredOutput?.Router != null) && (crosspointStore.StoredInput.Router != crosspointStore.StoredOutput.Router); cell.Style.ForeColor = invalidCrosspoint ? TEXT_COLOR_INVALID_CROSSPOINT : TEXT_COLOR_VALID_CROSSPOINT; }); builder.AddChangeEvent(nameof(CrosspointStore.StoredInput)); builder.AddChangeEvent(nameof(CrosspointStore.StoredOutput)); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredInput), nameof(RouterInput.Router), nameof(Router.ID)); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredInput), nameof(RouterInput.Router), nameof(Router.Name)); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredInput), nameof(RouterInput.Index)); builder.AddMultilevelChangeEvent(nameof(CrosspointStore.StoredInput), nameof(RouterInput.Name)); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void initFibTable(ref DataGridView originalTable, ref CustomDataGridView <FibEntry> customMember, Panel container, bool canDelete, FibTable fibTable) { customMember = CreateTable <FibEntry>(ref originalTable, container); CustomDataGridViewColumnDescriptorBuilder <FibEntry> builder; // Column: prefix, IP format builder = new CustomDataGridViewColumnDescriptorBuilder <FibEntry>(customMember); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Prefix"); builder.Width(120); builder.UpdaterMethod((entry, cell) => { cell.Value = entry.IpForm; }); builder.AddChangeEvent(nameof(FibEntry.IpForm)); builder.BuildAndAdd(); // Column: prefix, IP format builder = new CustomDataGridViewColumnDescriptorBuilder <FibEntry>(customMember); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Binary"); builder.Width(120); builder.UpdaterMethod((entry, cell) => { cell.Value = string.IsNullOrEmpty(entry.BinaryForm) ? "-" : entry.BinaryForm; }); builder.AddChangeEvent(nameof(FibEntry.BinaryForm)); builder.BuildAndAdd(); // Column: next hop builder = new CustomDataGridViewColumnDescriptorBuilder <FibEntry>(customMember); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Next hop"); builder.Width(100); builder.UpdaterMethod((entry, cell) => { cell.Value = entry.NextHop; }); builder.AddChangeEvent(nameof(FibEntry.NextHop)); builder.BuildAndAdd(); if (canDelete) { // Column: delete button builder = new CustomDataGridViewColumnDescriptorBuilder <FibEntry>(customMember); builder.Type(DataGridViewColumnType.Button); builder.Header("Delete"); builder.Width(70); builder.ButtonText("Delete"); builder.CellContentClickHandlerMethod((entry, cell, e) => { string msgBoxText = string.Format("Do you really want to delete this prefix?\n{0}", entry.IpForm); var confirm = MessageBox.Show(msgBoxText, "Delete confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm == DialogResult.Yes) { fibTable.RemoveEntry(entry); } }); builder.BuildAndAdd(); } // Bind database customMember.BoundCollection = fibTable; }
private void initOutputsTable() { outputsTableCDGV = createTable <RouterOutput>(outputsTableContainerPanel, ref this.outputsTable); CustomDataGridViewColumnDescriptorBuilder <RouterOutput> builder; // Column: index builder = getColumnDescriptorBuilderForTable <RouterOutput>(outputsTableCDGV); builder.Type(DataGridViewColumnType.TextBox); builder.Header("#"); builder.Width(30); builder.UpdaterMethod((output, cell) => { cell.Value = output.Index + 1; }); //builder.AddChangeEvent(nameof(RouterOutput.Index)); builder.BuildAndAdd(); // Column: name builder = getColumnDescriptorBuilderForTable <RouterOutput>(outputsTableCDGV); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Name"); builder.Width(100); builder.UpdaterMethod((output, cell) => { cell.Value = output.Name; }); builder.AddChangeEvent(nameof(RouterOutput.Name)); builder.TextEditable(true); builder.CellEndEditHandlerMethod((output, cell, eventargs) => { try { output.Name = cell.Value.ToString(); } catch (ArgumentException e) { MessageBox.Show(e.Message, "Data validation error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cell.Value = output.Name; } }); builder.BuildAndAdd(); // Column: delete button builder = getColumnDescriptorBuilderForTable <RouterOutput>(outputsTableCDGV); builder.Type(DataGridViewColumnType.Button); builder.Header("Delete"); builder.Width(70); builder.ButtonText("Delete"); builder.CellContentClickHandlerMethod((output, cell, e) => { string msgBoxText = string.Format("Do you really want to delete output #{0}?", (output.Index + 1)); var confirm = MessageBox.Show(msgBoxText, "Delete confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm == DialogResult.Yes) { router.RemoveOutput(output); } }); builder.BuildAndAdd(); // Bind collection outputsTableCDGV.BoundCollection = router.Outputs; }
public CustomDataGridView <T> CreateTable <T>(ref DataGridView insteadOf, Panel conainer) where T : class { var customTable = new CustomDataGridView <T>(); conainer.Controls.Clear(); conainer.Controls.Add(customTable); customTable.Dock = DockStyle.Fill; insteadOf = customTable; return(customTable); }
public CustomDataGridView <T> createTable <T>(Control container, ref DataGridView originalTableMember) where T : class { var customTable = new CustomDataGridView <T>(); container.Controls.Clear(); container.Controls.Add(customTable); customTable.Dock = DockStyle.Fill; originalTableMember = customTable; return(customTable); }
public CustomDataGridView <T> CreateTable <T>() where T : class { var customTable = new CustomDataGridView <T>(); bottomPanel.Controls.Clear(); bottomPanel.Controls.Add(customTable); customTable.Dock = DockStyle.Fill; this._table = customTable; return(customTable); }
private void baseColumnCreator(CustomDataGridView <Router> table, ItemListFormBaseManager <Router> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <Router> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: state builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("State"); builder.Width(100); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((router, cell) => { cell.Style.BackColor = stateColorConverter.Convert(router.State); cell.Value = router.StateString; }); builder.AddChangeEvent(nameof(Router.State)); builder.AddChangeEvent(nameof(Router.StateString)); // Column: inputs builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Inputs"); builder.Width(50); builder.UpdaterMethod((router, cell) => { cell.Value = router.Inputs.Count; }); builder.AddChangeEvent(nameof(Router.Inputs)); // Column: outputs builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Outputs"); builder.Width(50); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((router, cell) => { cell.Value = router.Outputs.Count; }); builder.AddChangeEvent(nameof(Router.Outputs)); // Column: crosspoints builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.Button); builder.Header("Crosspoints"); builder.Width(70); builder.ButtonText("Crosspoints"); builder.CellContentClickHandlerMethod((router, cell, e) => { new RouterControlForm(router).ShowAsChild(); }); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void baseColumnCreator(CustomDataGridView <TallyCopy> table, ItemListFormBaseManager <TallyCopy> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <TallyCopy> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: from signal builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("From signal"); builder.Width(150); builder.UpdaterMethod((tallyCopy, cell) => { cell.Value = tallyCopy.FromSignal.SignalLabel; }); builder.AddMultilevelChangeEvent(nameof(TallyCopy.FromSignal), nameof(ISignalSourceRegistered.SignalLabel)); // Column: from color builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("From color"); builder.Width(70); builder.UpdaterMethod((tallyCopy, cell) => { cell.Value = signalTallyColorTranslations.Convert(tallyCopy.FromTallyColor); cell.Style.BackColor = tallyCopy.FromTallyColor.ConvertToLightColor(); }); builder.AddChangeEvent(nameof(TallyCopy.FromTallyColor)); // Column: to signal builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("To signal"); builder.Width(150); builder.UpdaterMethod((tallyCopy, cell) => { cell.Value = tallyCopy.ToSignal.SignalLabel; }); builder.AddMultilevelChangeEvent(nameof(TallyCopy.ToSignal), nameof(ISignalSourceRegistered.SignalLabel)); // Column: to color builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("To color"); builder.Width(70); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((tallyCopy, cell) => { cell.Value = signalTallyColorTranslations.Convert(tallyCopy.ToTallyColor); cell.Style.BackColor = tallyCopy.ToTallyColor.ConvertToLightColor(); }); builder.AddChangeEvent(nameof(TallyCopy.ToTallyColor)); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void baseColumnCreator(CustomDataGridView <RouterMirror> table, ItemListFormBaseManager <RouterMirror> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <RouterMirror> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: router A builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Router A"); builder.Width(150); builder.UpdaterMethod((routerMirror, cell) => routerRefCellUpdaterMethod(routerMirror, cell, RouterMirrorSide.SideA)); builder.AddChangeEvent(nameof(RouterMirror.RouterA)); // Column: router B builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Router B"); builder.Width(150); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((routerMirror, cell) => routerRefCellUpdaterMethod(routerMirror, cell, RouterMirrorSide.SideB)); builder.AddChangeEvent(nameof(RouterMirror.RouterB)); // Column: sync A->B button builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.DisableButton); builder.Header("Sync A→B"); builder.Width(70); builder.ButtonText("Sync A→B"); builder.UpdaterMethod(syncButtonUpdaterMethod); builder.CellContentClickHandlerMethod((routerMirror, cell, e) => syncButtonClickMethod(routerMirror, RouterMirrorSide.SideA)); // Column: sync B->A button builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.DisableButton); builder.Header("Sync B→A"); builder.Width(70); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.ButtonText("Sync B→A"); builder.UpdaterMethod(syncButtonUpdaterMethod); builder.CellContentClickHandlerMethod((routerMirror, cell, e) => syncButtonClickMethod(routerMirror, RouterMirrorSide.SideB)); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void initLabelsTable() { labelsTableCDGV = createTable <LabelProxy>(labelsTableContainerPanel, ref this.labelsTable); CustomDataGridViewColumnDescriptorBuilder <LabelProxy> builder; // Column: router name builder = getColumnDescriptorBuilderForTable <LabelProxy>(labelsTableCDGV); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Router"); builder.Width(100); builder.UpdaterMethod((label, cell) => { cell.Value = label.RouterInput.Router.Name; }); //builder.AddChangeEvent(nameof(Model.Routers.Label.RouterInput.Router.Name)); builder.BuildAndAdd(); // Column: router input index builder = getColumnDescriptorBuilderForTable <LabelProxy>(labelsTableCDGV); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Input"); builder.Width(50); builder.UpdaterMethod((label, cell) => { cell.Value = label.RouterInput.Index + 1; }); //builder.AddChangeEvent(nameof(Model.Routers.Label.RouterInput.Index)); builder.BuildAndAdd(); // Column: text builder = getColumnDescriptorBuilderForTable <LabelProxy>(labelsTableCDGV); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Text"); builder.Width(100); builder.UpdaterMethod((label, cell) => { cell.Value = label.Text; }); builder.AddChangeEvent(nameof(LabelProxy.Text)); builder.TextEditable(true); builder.CellEndEditHandlerMethod((label, cell, eventargs) => { try { label.Text = cell.Value.ToString(); } catch (ArgumentException e) { MessageBox.Show(e.Message, "Data validation error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cell.Value = label.Text; } }); builder.BuildAndAdd(); // Bind collection labelsTableCDGV.BoundCollection = labelsetProxy; }
private void initializeTable() { table = CreateTable <IBoolean>(); CustomDataGridViewColumnDescriptorBuilder <IBoolean> builder; // Custom styles DataGridViewCellStyle stateColumnStyle = BOLD_TEXT_CELL_STYLE.Clone(); stateColumnStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; // Column: name builder = GetColumnDescriptorBuilderForTable <IBoolean>(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Name"); builder.CellStyle(BOLD_TEXT_CELL_STYLE); builder.Width(220); builder.UpdaterMethod((boolean, cell) => { cell.Value = boolean.Name; }); builder.AddChangeEvent(nameof(IBoolean.Name)); builder.BuildAndAdd(); // Column: description builder = GetColumnDescriptorBuilderForTable <IBoolean>(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Description"); builder.Width(450); builder.UpdaterMethod((boolean, cell) => { cell.Value = boolean.Description; }); builder.AddChangeEvent(nameof(IBoolean.Description)); builder.BuildAndAdd(); // Column: state builder = GetColumnDescriptorBuilderForTable <IBoolean>(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("State"); builder.CellStyle(stateColumnStyle); builder.Width(80); builder.UpdaterMethod((boolean, cell) => { bool booleanCurrentState = boolean.CurrentState; cell.Value = booleanCurrentState ? "- on -" : ""; cell.Style.BackColor = booleanCurrentState ? boolean.Color : OFF_COLOR; }); builder.AddChangeEvent(nameof(IBoolean.CurrentState)); builder.BuildAndAdd(); // Bind database table.BoundCollection = BooleanRegister.Instance; }
// etc... public MyControl() { // Define TableLayoutPanel properties here, // e.g. columns, rows, sizing... myDataGridControl = new CustomDataGridView(); // Define your custom DataGridView here. button1 = new Button(); // First button properties. button2 = new Button(); // Second button properties. // Assign these controls to TableLayoutPanel // in the specified cells. Controls.Add(myDataGridControl, 0, 0); Controls.Add(button1, 0, 1); Controls.Add(button2, 1, 1); }
private CustomDataGridView DataGridViewInitialization() { CustomDataGridView dataGridView = new CustomDataGridView(); dataGridView.Dock = DockStyle.Fill; dataGridView.Name = Properties.Settings.Default.CustomDataGridViewName; dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect; dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; dataGridView.Visible = true; dataGridView.ReadOnly = true; dataGridView.MultiSelect = false; dataGridView.ColumnHeadersVisible = false; dataGridView.RowHeadersVisible = false; dataGridView.AllowUserToResizeColumns = false; dataGridView.AllowUserToOrderColumns = false; dataGridView.AllowUserToResizeRows = false; dataGridView.AllowUserToDeleteRows = false; dataGridView.AllowUserToAddRows = false; dataGridView.VirtualMode = true; dataGridView.CellValueNeeded += CustomDataGridView_CellValueNeeded; dataGridView.SelectionChanged += CustomDataGridView_SelectionChanged; dataGridView.Columns.Clear(); for (int i = 0; i < _formModel.ArrayForSorting.GetLength(0); i++) { DataGridViewColumn column = new DataGridViewColumn(); column.FillWeight = 1; column.ReadOnly = true; column.CellTemplate = new DataGridViewTextBoxCell(); column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.Columns.Add(column); } dataGridView.RowCount = _formModel.ArrayForSorting.GetLength(0); return(dataGridView); }
public Form1() { Text = "Form1"; var dgv = new CustomDataGridView { Dock = DockStyle.Fill }; dgv.Columns.Add(new DataGridViewComboBoxColumn { HeaderText = "Header", DataSource = new string[] { "One", "Two", "Three", "Four" }, }); dgv.CommandKeyPress += new CommandKeyPressHandler(dgv_CommandKeyPress); Controls.Add(dgv); Controls.Add(new Button { Text = "Place holder", Dock = DockStyle.Top }); }
private void baseColumnCreator(CustomDataGridView <Salvo> table, ItemListFormBaseManager <Salvo> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <Salvo> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.DisableButton); builder.Header("Take"); builder.Width(70); builder.ButtonText("Take"); builder.CellContentClickHandlerMethod((salvo, cell, e) => salvo.Take()); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void baseColumnCreator(CustomDataGridView <DynamicText> table, ItemListFormBaseManager <DynamicText> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <DynamicText> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: current text builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header("Current text"); builder.Width(200); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((dyntext, cell) => { cell.Value = dyntext.CurrentText; }); builder.AddChangeEvent(nameof(DynamicText.CurrentText)); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
private void baseColumnCreator(CustomDataGridView <ExternalSignalCategory> table, ItemListFormBaseManager <ExternalSignalCategory> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod) { CustomDataGridViewColumnDescriptorBuilder <ExternalSignalCategory> builder; // Column: ID, name idColumnCreator(table, builderGetterMethod); nameColumnCreator(table, builderGetterMethod); // Column: color builder = builderGetterMethod(); builder.Type(DataGridViewColumnType.TextBox); builder.Header(""); builder.Width(30); builder.DividerWidth(DEFAULT_DIVIDER_WIDTH); builder.UpdaterMethod((category, cell) => { cell.Style.BackColor = category.Color; }); builder.AddChangeEvent(nameof(ExternalSignalCategory.Color)); // Column: edit, delete editButtonColumnCreator(table, builderGetterMethod); deleteButtonColumnCreator(table, builderGetterMethod); }
void SelectDataGridViewRow(TreeNode node, CustomDataGridView selectGridView, List <string> lstColName) { for (int i = 0; i < selectGridView.Rows.Count; i++) { bool flag = true; foreach (string colName in lstColName) { if ((string)selectGridView.Rows[i].Cells[colName].Value != node.Tag.ToString()) { flag = false; } } if (flag) { selectGridView.CurrentCell = selectGridView.Rows[i].Cells[1]; selectGridView.FirstDisplayedScrollingRowIndex = i; } } }
private void btnSaveAs_Click(object sender, EventArgs e) { try { CustomDataGridView view = this.GridView; if (view != null) { saveFileDialog1.Filter = Resources.Resource1.Form_ExcelFilter; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { string path = saveFileDialog1.FileName; view.SaveToFile(path); MessageBox.Show(Resources.Resource1.FrmReportBase_SaveSuccess); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Método necesario para admitir el Diseñador. No se puede modificar /// el contenido del método con el editor de código. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.findComboBox = new System.Windows.Forms.ComboBox(); this.maskedEdit = new System.Windows.Forms.MaskedTextBox(); this.checkBox = new System.Windows.Forms.CheckBox(); this.comboBox = new System.Windows.Forms.ComboBox(); this.dateTimePicker = new System.Windows.Forms.DateTimePicker(); this.multiColumnComboBox = new ExactTarget.Controls.ComboBox.MultiColumnComboBox(); this.textBox = new ExactTarget.Controls.TextBox.CustomTextBox(); this.comboBoxGrid = new ExactTarget.Controls.ComboBox.ComboBoxGrid(); this.customDataGridView = new ExactTarget.Controls.DataGridView.CustomDataGridView(); this.comboSimple = new System.Windows.Forms.ComboBox(); this.comboForm = new ExactTarget.Controls.ComboBox.ComboBoxForm(this.components); this.boton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.customDataGridView)).BeginInit(); this.SuspendLayout(); // // findComboBox // this.findComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.findComboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; this.findComboBox.FormattingEnabled = true; this.findComboBox.Location = new System.Drawing.Point(149, 48); this.findComboBox.Name = "findComboBox"; this.findComboBox.Size = new System.Drawing.Size(106, 21); this.findComboBox.TabIndex = 4; this.findComboBox.Visible = false; this.findComboBox.SelectedIndexChanged += new System.EventHandler(this.OnComboBoxSelectedIndexChanged); this.findComboBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // maskedEdit // this.maskedEdit.Location = new System.Drawing.Point(149, 22); this.maskedEdit.Name = "maskedEdit"; this.maskedEdit.Size = new System.Drawing.Size(106, 20); this.maskedEdit.TabIndex = 2; this.maskedEdit.Visible = false; this.maskedEdit.TextChanged += new System.EventHandler(this.OnControlTextChange); this.maskedEdit.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // checkBox // this.checkBox.BackColor = System.Drawing.SystemColors.Window; this.checkBox.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter; this.checkBox.Location = new System.Drawing.Point(149, 102); this.checkBox.Name = "checkBox"; this.checkBox.Size = new System.Drawing.Size(106, 20); this.checkBox.TabIndex = 8; this.checkBox.UseVisualStyleBackColor = false; this.checkBox.Visible = false; this.checkBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // comboBox // this.comboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.comboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox.FormattingEnabled = true; this.comboBox.Location = new System.Drawing.Point(38, 48); this.comboBox.Name = "comboBox"; this.comboBox.Size = new System.Drawing.Size(105, 21); this.comboBox.TabIndex = 3; this.comboBox.Visible = false; this.comboBox.SelectedIndexChanged += new System.EventHandler(this.OnComboBoxSelectedIndexChanged); this.comboBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // dateTimePicker // this.dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Short; this.dateTimePicker.Location = new System.Drawing.Point(150, 75); this.dateTimePicker.Name = "dateTimePicker"; this.dateTimePicker.Size = new System.Drawing.Size(105, 20); this.dateTimePicker.TabIndex = 6; this.dateTimePicker.Visible = false; this.dateTimePicker.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // multiColumnComboBox // this.multiColumnComboBox.BackColorEnter = System.Drawing.SystemColors.Window; this.multiColumnComboBox.BackColorLeave = System.Drawing.SystemColors.Window; this.multiColumnComboBox.ComboBoxHeight = 16; this.multiColumnComboBox.DropDownHeight = 98; this.multiColumnComboBox.DropDownWidth = 121; this.multiColumnComboBox.FontEnter = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.multiColumnComboBox.FontLeave = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.multiColumnComboBox.ForeColorEnter = System.Drawing.SystemColors.WindowText; this.multiColumnComboBox.ForeColorLeave = System.Drawing.SystemColors.WindowText; this.multiColumnComboBox.FormattingEnabled = true; this.multiColumnComboBox.Location = new System.Drawing.Point(38, 75); this.multiColumnComboBox.Name = "multiColumnComboBox"; this.multiColumnComboBox.Size = new System.Drawing.Size(106, 22); this.multiColumnComboBox.TabIndex = 5; this.multiColumnComboBox.Visible = false; this.multiColumnComboBox.SelectionChangeCommitted += new System.EventHandler(this.OnComboBoxSelectedIndexChanged); this.multiColumnComboBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // textBox // this.textBox.BackColorEnter = System.Drawing.SystemColors.Window; this.textBox.BackColorLeave = System.Drawing.SystemColors.Window; this.textBox.DataType = ExactTarget.Controls.Types.DataType.Alfanumerico; this.textBox.FontStyleEnter = System.Drawing.FontStyle.Bold; this.textBox.FontStyleLeave = System.Drawing.FontStyle.Regular; this.textBox.ForeColorEnter = System.Drawing.SystemColors.WindowText; this.textBox.ForeColorLeave = System.Drawing.SystemColors.WindowText; this.textBox.IsMayusculas = false; this.textBox.Location = new System.Drawing.Point(38, 22); this.textBox.MaxValue = 0; this.textBox.Name = "textBox"; this.textBox.NumberDecimals = 4; this.textBox.Size = new System.Drawing.Size(106, 20); this.textBox.TabIndex = 1; this.textBox.Visible = false; this.textBox.TextChanged += new System.EventHandler(this.OnControlTextChange); this.textBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // comboBoxGrid // this.comboBoxGrid.AllowResizeDropDown = true; this.comboBoxGrid.BackColorEnter = System.Drawing.SystemColors.Window; this.comboBoxGrid.BackColorLeave = System.Drawing.SystemColors.Window; this.comboBoxGrid.ControlSize = new System.Drawing.Size(240, 150); this.comboBoxGrid.DropDownSizeMode = ExactTarget.Controls.ComboBox.SimpleComboBox.SizeMode.UseControlSize; this.comboBoxGrid.DropSize = new System.Drawing.Size(200, 106); this.comboBoxGrid.FontEnter = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.comboBoxGrid.FontLeave = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.comboBoxGrid.ForeColorEnter = System.Drawing.SystemColors.WindowText; this.comboBoxGrid.ForeColorLeave = System.Drawing.SystemColors.WindowText; this.comboBoxGrid.Location = new System.Drawing.Point(38, 102); this.comboBoxGrid.Name = "comboBoxGrid"; this.comboBoxGrid.Size = new System.Drawing.Size(106, 21); this.comboBoxGrid.TabIndex = 7; this.comboBoxGrid.ValueReturned = null; this.comboBoxGrid.Visible = false; this.comboBoxGrid.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // customDataGridView // this.customDataGridView.AddNewRow = false; this.customDataGridView.AllowUserToAddRows = false; this.customDataGridView.AllowUserToDeleteRows = false; this.customDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; this.customDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.customDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; this.customDataGridView.Location = new System.Drawing.Point(0, 0); this.customDataGridView.Mode = ExactTarget.Controls.Types.Mode.ReadOnly; this.customDataGridView.Name = "customDataGridView"; this.customDataGridView.ReadOnly = true; this.customDataGridView.RowHeadersWidth = 20; this.customDataGridView.RowTemplate.Height = 24; this.customDataGridView.Size = new System.Drawing.Size(431, 150); this.customDataGridView.TabIndex = 0; this.customDataGridView.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.CustomDataGridViewCellEnter); this.customDataGridView.CellLeave += new System.Windows.Forms.DataGridViewCellEventHandler(this.CustomDataGridViewCellLeave); this.customDataGridView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.CustomDataGridViewScroll); this.customDataGridView.Paint += new System.Windows.Forms.PaintEventHandler(this.CustomDataGridViewPaint); this.customDataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CustomDataGridViewKeyDown); // // comboSimple // this.comboSimple.FormattingEnabled = true; this.comboSimple.Location = new System.Drawing.Point(273, 49); this.comboSimple.Name = "comboSimple"; this.comboSimple.Size = new System.Drawing.Size(121, 21); this.comboSimple.TabIndex = 10; this.comboSimple.Visible = false; this.comboSimple.SelectedIndexChanged += new System.EventHandler(this.OnComboBoxSelectedIndexChanged); this.comboSimple.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // comboForm // this.comboForm.BackColorEnter = System.Drawing.SystemColors.Window; this.comboForm.BackColorLeave = System.Drawing.SystemColors.Window; this.comboForm.Data = null; this.comboForm.DropDownForm = null; this.comboForm.DropDownHeight = 1; this.comboForm.FontEnter = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.comboForm.FontLeave = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.comboForm.ForeColorEnter = System.Drawing.SystemColors.WindowText; this.comboForm.ForeColorLeave = System.Drawing.SystemColors.WindowText; this.comboForm.FormattingEnabled = true; this.comboForm.IntegralHeight = false; this.comboForm.Location = new System.Drawing.Point(273, 75); this.comboForm.Name = "comboForm"; this.comboForm.Size = new System.Drawing.Size(121, 21); this.comboForm.TabIndex = 11; this.comboForm.Visible = false; this.comboForm.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ControlKeyUp); // // boton // this.boton.Location = new System.Drawing.Point(273, 102); this.boton.Name = "boton"; this.boton.Size = new System.Drawing.Size(121, 23); this.boton.TabIndex = 12; this.boton.UseVisualStyleBackColor = true; this.boton.Visible = false; // // DataGridViewUC // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.boton); this.Controls.Add(this.comboForm); this.Controls.Add(this.comboSimple); this.Controls.Add(this.comboBoxGrid); this.Controls.Add(this.multiColumnComboBox); this.Controls.Add(this.dateTimePicker); this.Controls.Add(this.findComboBox); this.Controls.Add(this.maskedEdit); this.Controls.Add(this.checkBox); this.Controls.Add(this.comboBox); this.Controls.Add(this.textBox); this.Controls.Add(this.customDataGridView); this.Name = "DataGridViewUC"; this.Size = new System.Drawing.Size(431, 150); ((System.ComponentModel.ISupportInitialize)(this.customDataGridView)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); }