private void Form1_Load(object sender, System.EventArgs e) { grid1.Redim(10, 5); grid1.SelectionMode = SourceGrid.GridSelectionMode.Row; //Setup the controllers CellClickEvent clickController = new CellClickEvent(); PopupMenu menuController = new PopupMenu(); CellCursor cursorController = new CellCursor(); SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.ToolTipTitle = "ToolTip example"; toolTipController.ToolTipIcon = ToolTipIcon.Info; toolTipController.IsBalloon = true; ValueChangedEvent valueChangedController = new ValueChangedEvent(); for (int r = 0; r < grid1.Rows.Count; r++) { if (r == 0) { grid1[r, 0] = new SourceGrid.Cells.ColumnHeader("Click event"); grid1[r, 1] = new SourceGrid.Cells.ColumnHeader("Custom Cursor"); grid1[r, 2] = new SourceGrid.Cells.ColumnHeader("ContextMenu"); grid1[r, 3] = new SourceGrid.Cells.ColumnHeader("ToolTip"); grid1[r, 4] = new SourceGrid.Cells.ColumnHeader("ValueChanged"); } else { grid1[r, 0] = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string)); grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); grid1[r, 2] = new SourceGrid.Cells.Cell("Right click"); grid1[r, 3] = new SourceGrid.Cells.Cell("Value " + r.ToString()); grid1[r, 3].ToolTipText = "Example of tooltip, bla bla bla ....\n Row: " + r.ToString(); grid1[r, 4] = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string)); } grid1[r, 0].AddController(clickController); grid1[r, 1].AddController(cursorController); grid1[r, 2].AddController(menuController); grid1[r, 3].AddController(toolTipController); grid1[r, 4].AddController(valueChangedController); } grid1.AutoSizeCells(); //Add the key controller to all the cells grid1.Controller.AddController(new KeyEvent(this)); }
/// <summary> /// グリッドを初期化する /// </summary> public override void initialGrid() { loadStyle(); clickController = new CellClickEvent(); //selectionClickController = new SelectionClickEvent(); toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.IsBalloon = false; // グリッドスタイル Grid.BorderStyle = BorderStyle.Fixed3D; Grid.Selection.EnableMultiSelection = false; Grid.DefaultHeight = (int)(TextRenderer.MeasureText("X", Grid.Font).Height * 1.5); setSelectionConfig(); // グリッドの列数 Grid.ColumnsCount = getColumnHeaderWidths().Length; //Grid.FixedRows = 1; setColorProfile(LinearGlobal.ColorConfig); }
const SG.EditableMode c_editableMode = SG.EditableMode.F2Key | SG.EditableMode.AnyKey; //default is these + doubleclick. See also OnMouseDown. public ParamGrid() { this.ColumnsCount = 2; //let the programmer set = 1 if need only for flags this.MinimumHeight = 18; //height when font is SegoeUI,9. With most other fonts it's smaller. this.SpecialKeys = SG.GridSpecialKeys.Default & ~SG.GridSpecialKeys.Tab; //this.AutoStretchColumnsToFitWidth = true; //does not work well. Instead we resize in OnClientSizeChanged etc. _editor = new Editors.TextBox(typeof(string)) { EditableMode = c_editableMode }; var c = _editor.Control; c.Multiline = true; //let all rows have the same multiline editor, even if the value cannot be multiline this.Controller.AddController(_controller = new _CellController(this)); //this.Controller.AddController(SG.Cells.Controllers.Resizable.ResizeWidth); //we resize width and height automatically, but the user may want to resize width. This is like in VS. Rejected because the control does not resize normally. _controllerTooltip0 = new SG.Cells.Controllers.ToolTipText() /*{ IsBalloon = true }*/; _controllerTooltip1 = new SG.Cells.Controllers.ToolTipText(); //this.Font = new Font("Verdana", 8); }
/// <summary> /// Occurs when loading this control. /// </summary> /// <param name="eventArgs"> /// The <see cref="EventArgs"/>. /// </param> protected override void OnLoad(EventArgs eventArgs) { const int numberOfRows = 6; const int numberOfCols = 4; grid.Redim(numberOfRows, numberOfCols); grid.FixedRows = 1; grid.FixedColumns = 1; grid.SelectionMode = SourceGrid.GridSelectionMode.Row; grid.ToolTipText = "Linked Controls"; grid[0, 0] = new SourceGrid.Cells.Header(null); // Create column header for (int i = 0; i < numberOfCols; i++) { string label; switch (i) { case 1: label = "Description"; break; case 2: label = "Value"; break; case 3: label = "Unit"; break; default: label = null; break; } var header = new SourceGrid.Cells.ColumnHeader(label) { AutomaticSortEnabled = false }; grid[0, i] = header; } // Create some entries SourceGrid.Cells.Views.Cell visualAspect = new SourceGrid.Cells.Views.Cell(); for (int i = 1; i < numberOfRows; i++) { string label; string unit; Control usedControl; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.IsBalloon = true; switch (i) { case 1: label = "Numeric Up Down [3...15]"; unit = "µs"; usedControl = new NumericUpDown(); (usedControl as NumericUpDown).Minimum = 3; (usedControl as NumericUpDown).Maximum = 15; (usedControl as NumericUpDown).Increment = 2; (usedControl as NumericUpDown).Value = 7; break; case 2: label = "Text box with max. length of 15 chars."; unit = ":o)"; usedControl = new TextBox(); (usedControl as TextBox).MaxLength = 15; (usedControl as TextBox).Text = "Some Text"; break; case 3: label = "Disabled text box"; unit = "^_^"; usedControl = new TextBox(); (usedControl as TextBox).Enabled = false; (usedControl as TextBox).Text = "Some disabled Text"; break; case 4: label = "Combo box with auto complete"; unit = "Prio."; usedControl = new ComboBox(); (usedControl as ComboBox).Items.AddRange( new object[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }); (usedControl as ComboBox).AutoCompleteMode = AutoCompleteMode.SuggestAppend; (usedControl as ComboBox).AutoCompleteSource = AutoCompleteSource.ListItems; break; default: label = "Progress bar"; unit = ""; Random randNmbr = new Random(); usedControl = new ProgressBar(); (usedControl as ProgressBar).Value = randNmbr.Next(0, 100); break; } grid[i, 1] = new SourceGrid.Cells.Cell { View = visualAspect, Value = label, ToolTipText = label + "..." + unit }; grid[i, 1].AddController(toolTipController); grid[i, 2] = new SourceGrid.Cells.Cell(); usedControl.Enter += delegate(object sender, EventArgs e) { IsRechangingSelection = true; foreach (RowInfo rowInfo in grid.Rows) { grid.Selection.SelectRow(rowInfo.Index, false); } foreach (LinkedControlValue lcv in grid.LinkedControls) { if (lcv.Control == usedControl) { grid.Selection.SelectRow(lcv.Position.Row, true); break; } } IsRechangingSelection = false; }; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(usedControl, new SourceGrid.Position(i, 2))); grid[i, 3] = new SourceGrid.Cells.Cell { View = visualAspect, Value = unit }; } if (grid.Columns[2].MinimalWidth < 127) { grid.Columns[2].MinimalWidth = 127; } grid.VScrollBar.ValueChanged += delegate(object sender, EventArgs valueChangedEventArgs) { // Hide all linked controls above 'new value' // Show all linked controls beyond 'new value' foreach (LinkedControlValue lcv in grid.LinkedControls) { lcv.Control.Visible = lcv.Position.Row > grid.VScrollBar.Value; } // Reselecting works more or less when scrolling down. But what when scrolling up? if (grid.Selection.ActivePosition.Row <= grid.VScrollBar.Value) { IsRechangingSelection = false; foreach (LinkedControlValue lcv in grid.LinkedControls) { grid.Selection.SelectRow(lcv.Position.Row, false); } IsRechangingSelection = true; grid.Selection.SelectRow(grid.VScrollBar.Value + 1, true); } }; // Focus the custom control when changing selection grid.Selection.SelectionChanged += delegate(object sender, RangeRegionChangedEventArgs e) { if (!IsRechangingSelection && e.AddedRange != null && e.RemovedRange == null) { bool isFound = false; int selectedRow = -1; int selectedCol = -1; int[] selectedRows = e.AddedRange.GetRowsIndex(); if (sender is SourceGrid.Selection.SelectionBase) { selectedRow = (sender as SourceGrid.Selection.SelectionBase).ActivePosition.Row; selectedCol = (sender as SourceGrid.Selection.SelectionBase).ActivePosition.Column; } if (selectedRows[0] != -1) { selectedRow = selectedRows[0]; } foreach (LinkedControlValue lcv in grid.LinkedControls) { if (lcv.Position.Row == selectedRow) { // Remove focus from control isFound = true; lcv.Control.Focus(); break; } } if (!isFound) { IsRechangingSelection = true; grid.Selection.Focus(new Position(selectedRow, selectedCol), true); IsRechangingSelection = false; } } }; }
private void Form1_Load(object sender, System.EventArgs e) { grid1.Redim(10, 5); //Setup the controllers CellClickEvent clickController = new CellClickEvent(); PopupMenu menuController = new PopupMenu(); CellCursor cursorController = new CellCursor(); SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.ToolTipTitle = "ToolTip example"; toolTipController.ToolTipIcon = ToolTipIcon.Info; toolTipController.IsBalloon = true; ValueChangedEvent valueChangedController = new ValueChangedEvent(); for (int r = 0; r < grid1.Rows.Count; r++) { if (r == 0) { grid1[r, 0] = new SourceGrid.Cells.ColumnHeader("Click event"); grid1[r, 1] = new SourceGrid.Cells.ColumnHeader("Custom Cursor"); grid1[r, 2] = new SourceGrid.Cells.ColumnHeader("ContextMenu"); grid1[r, 3] = new SourceGrid.Cells.ColumnHeader("ToolTip"); grid1[r, 4] = new SourceGrid.Cells.ColumnHeader("ValueChanged"); } else { grid1[r, 0] = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string)); grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); grid1[r, 2] = new SourceGrid.Cells.Cell("Right click"); grid1[r, 3] = new SourceGrid.Cells.Cell("Value " + r.ToString()); grid1[r, 3].ToolTipText = "Example of tooltip, bla bla bla ....\n Row: " + r.ToString(); grid1[r, 4] = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string)); } grid1[r, 0].AddController(clickController); grid1[r, 1].AddController(cursorController); grid1[r, 2].AddController(menuController); grid1[r, 3].AddController(toolTipController); grid1[r, 4].AddController(valueChangedController); } grid1.AutoSizeCells(); //Add the key controller to all the cells grid1.Controller.AddController(new KeyEvent(this)); }
private void FillResultGrid() { try { _selectedSolutionIndex = -1; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText { IsBalloon = true }; // remove existing rows gridSolutions.Rows.Clear(); // viewColumnHeader SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader() { Background = new DevAge.Drawing.VisualElements.ColumnHeader() { BackColor = Color.LightGray, Border = DevAge.Drawing.RectangleBorder.NoBorder }, ForeColor = Color.Black, Font = new Font("Arial", 8, FontStyle.Regular), }; viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None; // viewNormal CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); // set first row gridSolutions.BorderStyle = BorderStyle.FixedSingle; gridSolutions.ColumnsCount = 5; gridSolutions.FixedRows = 1; // header int iCol = 0; gridSolutions.Rows.Insert(0); gridSolutions[0, iCol] = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_INDEX) { View = viewColumnHeader }; gridSolutions[0, ++iCol] = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_LOADEDCASES) { View = viewColumnHeader }; gridSolutions[0, ++iCol] = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_NUMBEROFPALLETS) { View = viewColumnHeader }; gridSolutions[0, ++iCol] = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_LOADEDVOLUMEPERCENTAGE) { View = viewColumnHeader }; // solutions int iIndex = 0; foreach (HSolution sol in Solutions) { // insert row gridSolutions.Rows.Insert(++iIndex); iCol = 0; // name gridSolutions[iIndex, iCol] = new SourceGrid.Cells.Cell($"{iIndex}") { View = viewNormal, ToolTipText = sol.Algorithm }; gridSolutions[iIndex, iCol].AddController(toolTipController); gridSolutions[iIndex, ++iCol] = new SourceGrid.Cells.Cell(sol.LoadedCasesCountString) { View = viewNormal }; gridSolutions[iIndex, ++iCol] = new SourceGrid.Cells.Cell(sol.SolItemCount) { View = viewNormal }; gridSolutions[iIndex, ++iCol] = new SourceGrid.Cells.Cell(sol.LoadedVolumePercentage) { View = viewNormal }; } gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.Invalidate(); // select first solution if (gridSolutions.RowsCount > 1) { gridSolutions.Selection.SelectRow(1, true); } else { graphCtrl.Invalidate(); } } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void FillGrid() { try { // remove all existing rows gridSolutions.Rows.Clear(); // *** IViews // captionHeader SourceGrid.Cells.Views.RowHeader captionHeader = new SourceGrid.Cells.Views.RowHeader(); DevAge.Drawing.VisualElements.RowHeader veHeaderCaption = new DevAge.Drawing.VisualElements.RowHeader() { BackColor = Color.SteelBlue, Border = DevAge.Drawing.RectangleBorder.NoBorder }; captionHeader.Background = veHeaderCaption; captionHeader.ForeColor = Color.Black; captionHeader.Font = new Font("Arial", GridFontSize, FontStyle.Bold); captionHeader.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; // viewRowHeader SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader(); DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader() { BackColor = Color.LightGray, Border = DevAge.Drawing.RectangleBorder.NoBorder }; viewColumnHeader.Background = backHeader; viewColumnHeader.ForeColor = Color.Black; viewColumnHeader.Font = new Font("Arial", GridFontSize, FontStyle.Regular); viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None; // viewNormal CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); // *** // set first row gridSolutions.BorderStyle = BorderStyle.FixedSingle; gridSolutions.ColumnsCount = 7; gridSolutions.FixedRows = 1; gridSolutions.Rows.Insert(0); // header int iCol = 0, iRow = -1; gridSolutions.Rows.Insert(++iRow); // layer pattern gridSolutions[0, iCol++] = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERPATTERN) { AutomaticSortEnabled = false, View = viewColumnHeader }; // case count gridSolutions[0, iCol++] = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT) { AutomaticSortEnabled = false, View = viewColumnHeader }; // efficiency gridSolutions[0, iCol++] = new SourceGrid.Cells.ColumnHeader(Resources.ID_EFFICIENCYPERCENTAGE) { AutomaticSortEnabled = false, View = viewColumnHeader }; // pallet weight gridSolutions[0, iCol++] = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETWEIGHT, UnitsManager.MassUnitString)) { AutomaticSortEnabled = false, View = viewColumnHeader }; // pallet height gridSolutions[0, iCol++] = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, UnitsManager.LengthUnitString)) { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions.AutoStretchRowsToFitHeight = true; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText { ToolTipTitle = "", ToolTipIcon = ToolTipIcon.None, IsBalloon = false }; foreach (Layer2D layer in _layers) { gridSolutions.Rows.Insert(++iRow); iCol = 0; // layer pattern gridSolutions[iRow, iCol] = new SourceGrid.Cells.Image(TryGenerateLayerImage(layer)) { ToolTipText = layer.Name }; gridSolutions[iRow, iCol++].AddController(toolTipController); using (FastEvaluatorLayer2Pallet evaluator = new FastEvaluatorLayer2Pallet(layer, SelectedPackable, SelectedPallet, BuildConstraintSet())) { // case count gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell( string.Format(Resources.ID_CASECOUNTFORMATSTRING, evaluator.ItemCount, evaluator.NoItemsPerLayer, evaluator.NoLayers)); // volume efficiency gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format(CultureInfo.InvariantCulture, "{0:0.##}", evaluator.VolumeEfficiency)); // pallet weight gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format(CultureInfo.InvariantCulture, "{0:0.#}", evaluator.PalletWeight)); // pallet height gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format(CultureInfo.InvariantCulture, "{0:0.##}", evaluator.PalletHeight)); } } gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution if (gridSolutions.RowsCount > 1) { gridSolutions.Selection.SelectRow(1, true); } else { graphCtrl.Invalidate(); } } catch (Exception ex) { _log.Error(ex.Message); } }
/// <summary> /// Evénement lors d'un click sur la liste des documents /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstDocuments_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { int numLigne = p_applClass.Param.MailSettings.ListDocuments.Count; // Mise à jour des informations if (lstDocuments.Selection.ActivePosition.Row == -1) { return; } if (lstDocuments.Selection.ActivePosition.Row > p_applClass.Param.MailSettings.ListDocuments.Count) { p_update = false; openFile.Filter = "Tous les fichiers (*.*)|*.*"; DialogResult dialog = openFile.ShowDialog(); if (dialog == System.Windows.Forms.DialogResult.OK) { string _fileName = openFile.SafeFileName; string _filePath = openFile.FileName; p_applClass.Param.MailSettings.ListDocuments.Add(new AttachDocument(_fileName, _filePath)); SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.ToolTipTitle = "Chemin d'accès au document"; toolTipController.ToolTipIcon = ToolTipIcon.Info; toolTipController.IsBalloon = true; numLigne++; lstDocuments.Rows.Insert(numLigne); lstDocuments[numLigne, 0] = new SourceGrid.Cells.Cell(_fileName); lstDocuments[numLigne, 1] = new SourceGrid.Cells.Cell(_filePath); lstDocuments[numLigne, 1].ToolTipText = _filePath; lstDocuments[numLigne, 1].AddController(toolTipController); } } else { p_update = true; int numDocument = lstDocuments.Selection.ActivePosition.Row - 1; string _filePath = p_applClass.Param.MailSettings.ListDocuments[numDocument].FilePath; if (MessageBox.Show("Confirmer la suppression de ce document ?", "Confirmer", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { p_applClass.Param.MailSettings.ListDocuments.RemoveAt(numDocument); lstDocuments.Rows.Remove(numDocument + 1); } } }
/// <summary> /// Chargement de la Liste des Photographes /// </summary> private void loadLstDocument() { int numLigne = 0; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.ToolTipTitle = "Chemin d'accès au document"; toolTipController.ToolTipIcon = ToolTipIcon.Info; toolTipController.IsBalloon = true; if (p_applClass.Param.MailSettings != null) { for (int i = 0; i < p_applClass.Param.MailSettings.ListDocuments.Count; i++) { numLigne++; lstDocuments.Rows.Insert(numLigne); lstDocuments[numLigne, 0] = new SourceGrid.Cells.Cell(p_applClass.Param.MailSettings.ListDocuments[i].FileName); lstDocuments[numLigne, 1] = new SourceGrid.Cells.Cell(p_applClass.Param.MailSettings.ListDocuments[i].FilePath); lstDocuments[numLigne, 1].ToolTipText = p_applClass.Param.MailSettings.ListDocuments[i].FilePath; lstDocuments[numLigne, 1].AddController(toolTipController); } } numLigne++; lstDocuments.Rows.Insert(numLigne); lstDocuments[numLigne, 0] = new SourceGrid.Cells.Cell("Cliquer pour ajouter un document"); lstDocuments[numLigne, 0].ColumnSpan = 2; }
/// <summary> /// Chargement de la Liste des Documents /// </summary> private void loadLstDocument() { lstDocuments.BorderStyle = BorderStyle.FixedSingle; lstDocuments.ColumnsCount = 2; lstDocuments.FixedRows = 1; lstDocuments.Rows.Insert(0); lstDocuments.Selection.FocusStyle = FocusStyle.None; lstDocuments.SelectionMode = GridSelectionMode.Row; lstDocuments[0, 0] = new SourceGrid.Cells.ColumnHeader("Nom"); lstDocuments[0, 1] = new SourceGrid.Cells.ColumnHeader("Chemin"); lstDocuments.Columns.SetWidth(0, 150); lstDocuments.Columns.SetWidth(1, 200); int numLigne = 0; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.ToolTipTitle = "Chemin d'accès au document"; toolTipController.ToolTipIcon = ToolTipIcon.Info; toolTipController.IsBalloon = true; for (int i = 0; i < p_listDocuments.Count; i++) { numLigne++; lstDocuments.Rows.Insert(numLigne); lstDocuments[numLigne, 0] = new SourceGrid.Cells.Cell(p_listDocuments[i].FileName); lstDocuments[numLigne, 1] = new SourceGrid.Cells.Cell(p_listDocuments[i].FilePath); lstDocuments[numLigne, 1].ToolTipText = p_listDocuments[i].FilePath; lstDocuments[numLigne, 1].AddController(toolTipController); } numLigne++; lstDocuments.Rows.Insert(numLigne); lstDocuments[numLigne, 0] = new SourceGrid.Cells.Cell("Cliquer pour ajouter un document"); lstDocuments[numLigne, 0].ColumnSpan = 2; }
public RuleGrid() { SpecialKeys = GridSpecialKeys.None | GridSpecialKeys.Enter | GridSpecialKeys.Escape | GridSpecialKeys.PageDownUp; SelectionMode = SourceGrid.GridSelectionMode.Row; BackColor = System.Drawing.SystemColors.Window; BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; // padding-right = 4 for ellipse text drag-select ColumnsCount = 5; RowsCount = 1; FixedRows = 1; // Initialise custom editors emptyEditor = new EditorBase(typeof(int)); emptyEditor.EnableEdit = false; readOnlyEditor = new EditorBase(typeof(String)); readOnlyEditor.EnableEdit = false; //ruleTypeEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); //ruleTypeEditor.StandardValues = new string[] { "Delete", "Copy", "Replace" }; //ruleTypeEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick; //ruleTypeEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList; emptyGray = new SourceGrid.Cells.Views.Cell(); emptyGray.BackColor = System.Drawing.SystemColors.ControlDark; popMenu = new PopupMenu(this); //Header this[0, ColControl] = new SourceGrid.Cells.ColumnHeader(Textual.Enabled); this[0, ColType] = new SourceGrid.Cells.ColumnHeader(Textual.RuleType); this[0, ColDestination] = new SourceGrid.Cells.ColumnHeader(Textual.DestinationTag + "(?)"); this[0, ColReplacement] = new SourceGrid.Cells.ColumnHeader(Textual.ReplacementText); this[0, ColPattern] = new SourceGrid.Cells.ColumnHeader(Textual.SearchPatterns); this.Columns[ColControl].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; this.Columns[ColType].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; this.Columns[ColDestination].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; this.Columns[ColReplacement].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; this.Columns[ColPattern].AutoSizeMode = SourceGrid.AutoSizeMode.Default | SourceGrid.AutoSizeMode.MinimumSize; this.Columns[ColPattern].MinimalWidth = 800; this.AutoStretchColumnsToFitWidth = true; //Columns.AutoSize(true); //ScrollBar = ScrollBars.Vertical; //this.VScroll = true; //this.SetVScrollBarVisible(true); this[0, ColDestination].ToolTipText = Textual.DestinationTagTooltip; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.IsBalloon = true; this[0, ColDestination].Controller.AddController(toolTipController); foreach(int i in new int[]{ColControl, ColType, ColDestination, ColReplacement, ColPattern}) { this[0, i].RemoveController(this[0, i].FindController(typeof(SourceGrid.Cells.Controllers.SortableHeader))); } AutoSizeCells(); }
/// <summary> /// Occurs when loading this control. /// </summary> /// <param name="eventArgs"> /// The <see cref="EventArgs"/>. /// </param> protected override void OnLoad(EventArgs eventArgs) { const int numberOfRows = 6; const int numberOfCols = 4; grid.Redim(numberOfRows, numberOfCols); grid.FixedRows = 1; grid.FixedColumns = 1; grid.SelectionMode = SourceGrid.GridSelectionMode.Row; grid.ToolTipText = "Linked Controls"; grid[0, 0] = new SourceGrid.Cells.Header(null); // Create column header for (int i = 0; i < numberOfCols; i++) { string label; switch (i) { case 1: label = "Description"; break; case 2: label = "Value"; break; case 3: label = "Unit"; break; default: label = null; break; } var header = new SourceGrid.Cells.ColumnHeader(label) { AutomaticSortEnabled = false }; grid[0, i] = header; } // Create some entries SourceGrid.Cells.Views.Cell visualAspect = new SourceGrid.Cells.Views.Cell(); for (int i = 1; i < numberOfRows; i++) { string label; string unit; Control usedControl; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.IsBalloon = true; switch (i) { case 1: label = "Numeric Up Down [3...15]"; unit = "µs"; usedControl = new NumericUpDown(); (usedControl as NumericUpDown).Minimum = 3; (usedControl as NumericUpDown).Maximum = 15; (usedControl as NumericUpDown).Increment = 2; (usedControl as NumericUpDown).Value = 7; break; case 2: label = "Text box with max. length of 15 chars."; unit = ":o)"; usedControl = new TextBox(); (usedControl as TextBox).MaxLength = 15; (usedControl as TextBox).Text = "Some Text"; break; case 3: label = "Disabled text box"; unit = "^_^"; usedControl = new TextBox(); (usedControl as TextBox).Enabled = false; (usedControl as TextBox).Text = "Some disabled Text"; break; case 4: label = "Combo box with auto complete"; unit = "Prio."; usedControl = new ComboBox(); (usedControl as ComboBox).Items.AddRange( new object[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }); (usedControl as ComboBox).AutoCompleteMode = AutoCompleteMode.SuggestAppend; (usedControl as ComboBox).AutoCompleteSource = AutoCompleteSource.ListItems; break; default: label = "Progress bar"; unit = ""; Random randNmbr = new Random(); usedControl = new ProgressBar(); (usedControl as ProgressBar).Value = randNmbr.Next(0, 100); break; } grid[i, 1] = new SourceGrid.Cells.Cell { View = visualAspect, Value = label, ToolTipText = label + "..." + unit }; grid[i, 1].AddController(toolTipController); grid[i, 2] = new SourceGrid.Cells.Cell(); usedControl.Enter += delegate(object sender, EventArgs e) { IsRechangingSelection = true; foreach (RowInfo rowInfo in grid.Rows) { grid.Selection.SelectRow(rowInfo.Index, false); } foreach (LinkedControlValue lcv in grid.LinkedControls) { if (lcv.Control == usedControl) { grid.Selection.SelectRow(lcv.Position.Row, true); break; } } IsRechangingSelection = false; }; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(usedControl, new SourceGrid.Position(i, 2))); grid[i, 3] = new SourceGrid.Cells.Cell { View = visualAspect, Value = unit }; } if (grid.Columns[2].MinimalWidth < 127) { grid.Columns[2].MinimalWidth = 127; } grid.VScrollBar.ValueChanged += delegate(object sender, EventArgs valueChangedEventArgs) { // Hide all linked controls above 'new value' // Show all linked controls beyond 'new value' foreach (LinkedControlValue lcv in grid.LinkedControls) { lcv.Control.Visible = lcv.Position.Row > grid.VScrollBar.Value; } // Reselecting works more or less when scrolling down. But what when scrolling up? if (grid.Selection.ActivePosition.Row <= grid.VScrollBar.Value) { IsRechangingSelection = false; foreach (LinkedControlValue lcv in grid.LinkedControls) { grid.Selection.SelectRow(lcv.Position.Row, false); } IsRechangingSelection = true; grid.Selection.SelectRow(grid.VScrollBar.Value + 1, true); } }; // Focus the custom control when changing selection grid.Selection.SelectionChanged += delegate(object sender, RangeRegionChangedEventArgs e) { if (!IsRechangingSelection && e.AddedRange != null && e.RemovedRange == null) { bool isFound = false; int selectedRow = -1; int selectedCol = -1; int[] selectedRows = e.AddedRange.GetRowsIndex(); if (sender is SourceGrid.Selection.SelectionBase) { selectedRow = (sender as SourceGrid.Selection.SelectionBase).ActivePosition.Row; selectedCol = (sender as SourceGrid.Selection.SelectionBase).ActivePosition.Column; } if (selectedRows[0] != -1) { selectedRow = selectedRows[0]; } foreach (LinkedControlValue lcv in grid.LinkedControls) { if (lcv.Position.Row == selectedRow) { // Remove focus from control isFound = true; lcv.Control.Focus(); break; } } if (!isFound) { IsRechangingSelection = true; grid.Selection.Focus(new Position(selectedRow, selectedCol), true); IsRechangingSelection = false; } } }; }