public void SelectRow_ShouldMaintain_ActivePosition() { // set up special conditions var grid = new Grid(); grid.Redim(1, 1); grid[0, 0] = new Cell(); var form = new Form(); form.Controls.Add(grid); form.Show(); grid.SelectionMode = GridSelectionMode.Row; grid.Selection.EnableMultiSelection = false; // just assert that we have correct conditions for test, // active position should not be empty grid.Selection.Focus(new Position(0, 0), true); Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition); // this method causes first row to be selected. Should not fail // it failed once in RowSelection.SelectRow method // As call to ResetSelection asked to maintain focus, a stack overflow was raised grid.Selection.SelectRow(0, true); Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition); // destroy form.Close(); form.Dispose(); }
public void AttachedExistingSpannedCell_AddCellLater() { Grid grid1 = new Grid(); grid1.Redim(1, 40); var cell = new SourceGrid.Cells.Cell(); cell.ColumnSpan = 5; // this line should not throw exception, since everything is ok grid1[0, 0] = cell; // this line should throw exception, as there is a spanned cell // already var b = false; try { grid1[0, 1] = new SourceGrid.Cells.Cell(); } catch (OverlappingCellException) { b = true; } Assert.AreEqual(b, true); }
public void AttachedExistingSpannedCell() { Grid grid1 = new Grid(); grid1.Redim(1, 4); var cell = new SourceGrid.Cells.Cell(); cell.ColumnSpan = 5; grid1[0, 1] = new SourceGrid.Cells.Cell(); var b = false; // this line should throw exception try { grid1[0, 0] = cell; } catch (OverlappingCellException) { b = true; } Assert.AreEqual(b, true); }
public void UpdateCellIcon(int rowIndex, ActionBase actionObject) { this[rowIndex, 0] = new SourceGrid.Cells.Cell(""); Bitmap breakBitmap = GetBreakPointIcon(actionObject); if (breakBitmap != null) { this[rowIndex, 0].Image = breakBitmap; } else { Bitmap statueIcon = GetStatueIcon(actionObject); AppContext context = actionObject.AppContext as AppContext; if (statueIcon != null && context.State.IsRunning) { this[rowIndex, 0].Image = statueIcon; this[rowIndex, 0].ToolTipText = actionObject.ErrorMessage; } else { this[rowIndex, 0].Image = actionObject.GetIcon(); } } InvalidateCell(new Position(rowIndex, 0)); }
private void SetupMarketDataGridRow(Grid grid, int r) { if (grid.Rows.Count <= r) { grid.Rows.Insert(r); } for (var i = 0; i <= (int)LAST_CONTRACT_DETAILS_COLUMN; i++) { Type t = grid[1, (int)i].Tag as Type; grid[r, i] = new SourceGrid.Cells.Cell(null, t) { Tag = t, View = _yellowView }; } for (var i = (int)LAST_CONTRACT_DETAILS_COLUMN + 1; i < (int)IBGridColumn.LAST_COLUMN; i++) { var cell = new SourceGrid.Cells.Cell(0.0); grid[r, i] = cell; var alternate = (r % 2 != 0); if (i <= (int)LAST_STATUS_DETAILS_COLUMN) { cell.View = alternate ? _lightGreen : _darkGreen; } else { cell.View = alternate ? _whiteView : _lightGray; } } grid.Rows[r].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; }
private static Grid SingeCellGrid(int rowCount, int columnCount, string cellValue) { var grid = NewGrid(rowCount, columnCount); grid[0, 0] = new SourceGrid.Cells.Cell(cellValue); return(grid); }
public void Fill(CalendarOptions options) { this.Rows.Clear(); createGridHeader(); for (int i = 0; i < PluginsManager.Instance.Modules.Length; i++) { int newRowIndex = Rows.Count; Rows.Insert(newRowIndex); var row = Rows[newRowIndex]; var module = PluginsManager.Instance.Modules[i]; row.Tag = module.GlobalId; string text = EntryObjectLocalizationManager.Instance.GetString(module.EntryObjectType, LocalizationConstants.EntryObjectName); var cell = new SourceGrid.Cells.Cell(text); cell.Image = module.ModuleImage; this[newRowIndex, 0] = cell; bool isChecked = true; if (options.ShowIcons.ContainsKey(module.GlobalId)) { isChecked = options.ShowIcons[module.GlobalId]; } cell = new SourceGrid.Cells.CheckBox(null, isChecked); this[newRowIndex, 1] = cell; isChecked = options.GetDefaultEntry(module.GlobalId); cell = new SourceGrid.Cells.CheckBox(null, isChecked); this[newRowIndex, 2] = cell; } Columns.AutoSizeColumn(0); }
public void Bug5239() { var grid1 = new Grid(); grid1.Redim(4, 1); grid1.FixedRows = 1; for (int r = 0; r < grid1.RowsCount; r++) { if (r % 2 == 0) { grid1[r, 0] = new SourceGrid.Cells.Cell(); grid1[r, 0].ColumnSpan = 2; } } // sort all cells var range = new Range(0, 0, grid1.Rows.Count - 1, grid1.Columns.Count - 1); grid1.SortRangeRows(range, 0, true, null); // loop via all cells for (var i = 0; i < grid1.Rows.Count; i++) { for (var col = 0; col < grid1.Columns.Count; col++) { // here we get exception : // Grid should contain a spanned cell at position 0;0, but apparently it does not! var cell = grid1[i, col]; } } }
public virtual void MakeFirstCell(uint addpos = 0) { var grid = GridRow.Grid as MyGrid; int i = GridRow.Index + (int)addpos; grid[i, 0] = new SourceGrid.Cells.Cell(""); grid[i, 0].View = grid.gridViewModel.rowHeaderModel; grid[i, 0].AddController(RowMarkCellController.Default); }
/// <summary> /// 更新变量活动行内容 /// </summary> protected override void UpdateRow(int rowIndex, ActionBase actionObject) { //变量名称 string elementValue = actionObject.ElementName; this[rowIndex, 2] = new SourceGrid.Cells.Cell(elementValue); //变量值 this[rowIndex, 3] = new SourceGrid.Cells.Cell(actionObject.ToString()); }
public void AddEmptyCells(Range range) { for (int i = range.Start.Row; i <= range.End.Row; i++) for (int i1 = range.Start.Column; i1 <= range.End.Column; i1++) { if (this.Grid[i, i1] == null) Grid[i, i1] = new Cell(); } }
public virtual SourceGrid.Cells.Cell MakeCaptionCell() { var grid = GridRow.Grid as MyGrid; int i = GridRow.Index; var newcell = new SourceGrid.Cells.Cell(RowTitle); grid[i, CaptionColumnNr] = newcell; newcell.View = grid.gridViewModel.captionModel; return(newcell); }
public void AddEmptyRow() { int newRowIndex = Rows.Count; Rows.Insert(newRowIndex); SuplementTypeCellValueChangedController suplementController = new SuplementTypeCellValueChangedController(this, entry); var lookupEditor = new LookupEditEditor(typeof(Guid)); this[newRowIndex, SuplementTypeColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell(); this[newRowIndex, SuplementTypeColumn].View = readOnlyView; this[newRowIndex, SuplementTypeColumn].View.ForeColor = ApplicationColors.FGNullText; this[newRowIndex, SuplementTypeColumn].AddController(suplementController); this[newRowIndex, SuplementTypeColumn].Editor.NullDisplayString = SuplementsEntryStrings.SelectSuplementType; readOnlyView = new SourceGrid.Cells.Views.Cell(); var textBox = new SourceGrid.Cells.Editors.TextBox(typeof(string)); textBox.Control.MaxLength = Constants.NameColumnLength; this[newRowIndex, SuplementNameColumn] = new SourceGrid.Cells.Cell(null, textBox); this[newRowIndex, SuplementNameColumn].View = readOnlyView; readOnlyView = new SourceGrid.Cells.Views.Cell(); ////grid1[newRowIndex, 1].AddController(ee); this[newRowIndex, InfoColumn] = new SourceGrid.Cells.Cell(null, new MemoExEditEditor()); this[newRowIndex, InfoColumn].View = readOnlyView; this[newRowIndex, InfoColumn].AddController(commentableCellController); this[newRowIndex, InfoColumn].Column.Width = 80; var maskEditor = new MaskEditEditor(); maskEditor.MaskRegEx = string.Format("[0-9]*{0}?[0-9]*", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); this[newRowIndex, DosageColumn] = new SourceGrid.Cells.Cell(null, maskEditor); this[newRowIndex, DosageColumn].View = readOnlyView; SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(ComboBoxItem)); //cbEditor.StandardValues = Enum.GetValues(typeof (DosageType)); foreach (DosageType type in Enum.GetValues(typeof(DosageType))) { cbEditor.Control.Items.Add(new BodyArchitect.Controls.ComboBoxItem(type, EnumLocalizer.Default.Translate(type))); } cbEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList; this[newRowIndex, DosageTypeColumn] = new SourceGrid.Cells.Cell(null, cbEditor); this[newRowIndex, DosageTypeColumn].View = readOnlyView; this[newRowIndex, DosageTypeColumn].Column.Width = 80; var timeEditor = new TimeEditEditor(); this[newRowIndex, TimeColumn] = new SourceGrid.Cells.Cell(null, timeEditor); this[newRowIndex, TimeColumn].View = new TimeEditView(); UpdateCellsReadOnlyMode(Rows[newRowIndex]); }
private void ClientError(object sender, TWSClientErrorEventArgs e) { var i = 0; logGrid.Rows.Insert(_logGridRow); logGrid[_logGridRow, i] = new SourceGrid.Cells.Cell(DateTime.Now); logGrid[_logGridRow, i].View = _defaultViewClearType; logGrid[_logGridRow, 1] = new SourceGrid.Cells.Cell(e.RequestId); logGrid[_logGridRow, 2] = new SourceGrid.Cells.Cell(e.Error.Code); logGrid[_logGridRow, 3] = new SourceGrid.Cells.Cell(e.Error.Message); }
public void SetUp() { m_grid = new Grid(); m_grid.ClipboardMode = ClipboardMode.All; m_grid.Redim(2, 2); m_grid[0, 0] = new Cell(m_firstValue, typeof(int)); m_grid[1, 1] = new Cell(m_secondValue, typeof(int)); Assert.AreEqual(m_firstValue, m_grid[0, 0].Value); Assert.AreEqual(m_secondValue, m_grid[1, 1].Value); }
public void InsertOverlappingCell() { SourceGrid.Grid grid1 = new Grid(); grid1.Redim(2, 2); // this cell should span both to the right, and to the left grid1[0, 0] = new SourceGrid.Cells.Cell("Text Span", typeof(string));; grid1[0, 0].ColumnSpan = 2; grid1[0, 1] = new SourceGrid.Cells.Cell("This should throw OverlappingCellException"); }
public void PositionToCellRange() { Grid grid1 = new Grid(); grid1.Redim(6, 6); grid1[0, 0] = new SourceGrid.Cells.Cell(); grid1[0, 0].ColumnSpan = 3; grid1[0, 0].RowSpan = 3; Assert.AreEqual(new Range(0, 0, 2, 2), grid1.PositionToCellRange(new Position(0, 0))); }
private void PopulateCell(int p_GridRow, int p_GridCol, System.Reflection.PropertyInfo p_PropInfo, Cells.Editors.EditorBase p_Editor, object p_Object) { grid[p_GridRow, p_GridCol] = new Cells.Cell(p_PropInfo.GetValue(p_Object, null)); grid[p_GridRow, p_GridCol].Editor = p_Editor; Cells.Controllers.BindProperty l_Bind = new Cells.Controllers.BindProperty(p_PropInfo, p_Object); grid[p_GridRow, p_GridCol].AddController(l_Bind); Cells.Controllers.CustomEvents l_CustomEvents = new Cells.Controllers.CustomEvents(); l_CustomEvents.ValueChanged += new EventHandler(Grid_ValueChanged); grid[p_GridRow, p_GridCol].AddController(l_CustomEvents); }
public void ModifyColumnSpan_ToCauseOverlapping() { SourceGrid.Grid grid1 = new Grid(); grid1.Redim(2, 6); // this cell should span both to the right, and to the left grid1[0, 4] = new SourceGrid.Cells.Cell("cell to span", typeof(string)); grid1[0, 5] = new SourceGrid.Cells.Cell("cell to overlap", typeof(string)); // this should throw exception grid1[0, 4].ColumnSpan = 2; }
public void ModifyRowSpan_ToCauseOverlapping() { SourceGrid.Grid grid1 = new Grid(); grid1.Redim(6, 2); // this cell should span both to the right, and to the left grid1[4, 0] = new SourceGrid.Cells.Cell("cell to span", typeof(string)); grid1[5, 0] = new SourceGrid.Cells.Cell("cell to overlap", typeof(string)); // this should throw exception grid1[4, 0].RowSpan = 2; }
public void RangeToCellRange_WithNullCell() { Grid grid1 = new Grid(); grid1.Redim(6, 6); grid1[0, 0] = new SourceGrid.Cells.Cell(); grid1[0, 1] = new SourceGrid.Cells.Cell(); grid1[1, 0] = new SourceGrid.Cells.Cell(); grid1[1, 1] = null; Assert.AreEqual(new Range(0, 0, 1, 1), grid1.RangeToCellRange(new Range(0, 0, 1, 1))); }
public void Bug0003() { var grid = new Grid(); int rowCount = 10, colCount = 10; grid.Redim(rowCount, colCount); grid[0, 0] = new SourceGrid.Cells.Cell(); grid[0, 0].ColumnSpan = 3; grid.Rows.Insert(0); grid[0, 0] = new SourceGrid.Cells.Cell(); grid[0, 0].ColumnSpan = 3; }
public void AddEmptyRow() { int newRowIndex = grid1.Rows.Count; grid1.Rows.Insert(newRowIndex); var lookupEditor = new LookupEditEditor(typeof(Guid)); LookUpColumnInfo selectedCol = (LookUpColumnInfo)((ComboBoxItem)cmbExerciseViewType.SelectedItem).Tag; lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, FromExerciseColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, FromExerciseColumn].View = readOnlyView; grid1[newRowIndex, FromExerciseColumn].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, FromExerciseColumn].AddController(mapperCtrl); grid1[newRowIndex, FromExerciseColumn].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, FromExerciseColumn].Column.Width = 250; readOnlyView = new SourceGrid.Cells.Views.Cell(); lookupEditor = new LookupEditEditor(typeof(Guid)); lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, ToExerciseColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, ToExerciseColumn].View = readOnlyView; grid1[newRowIndex, ToExerciseColumn].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, ToExerciseColumn].AddController(mapperCtrl); grid1[newRowIndex, ToExerciseColumn].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, ToExerciseColumn].Column.Width = 250; SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(ComboBoxItem)); //cbEditor.StandardValues = Enum.GetValues(typeof(MapperEntryOperation)); foreach (MapperEntryOperation type in Enum.GetValues(typeof(MapperEntryOperation))) { cbEditor.Control.Items.Add(new ComboBoxItem(type, EnumLocalizer.Default.Translate(type))); } cbEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList; cbEditor.Control.SelectedIndex = 0; readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, OperationColumn] = new SourceGrid.Cells.Cell(null, cbEditor); grid1[newRowIndex, OperationColumn].View = readOnlyView; grid1[newRowIndex, OperationColumn].Column.Width = 80; UpdateCellsReadOnlyMode(grid1.Rows[newRowIndex]); }
private void frmSample17_Load(object sender, System.EventArgs e) { grid1.Redim(100, 40); grid1.FixedColumns = 0; grid1.FixedRows = 0; grid1[0, 0] = new SourceGrid.Cells.Header(null); for (int c = 1; c < grid1.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader("Header " + c.ToString()); header.AutomaticSortEnabled = false; //header.ColumnSelectorEnabled = true; //header.ColumnFocusEnabled = true; grid1[0, c] = header; } Random rnd = new Random(); for (int r = 1; r < grid1.RowsCount; r++) { grid1[r, 0] = new SourceGrid.Cells.RowHeader("Header " + r.ToString()); for (int c = 1; c < grid1.ColumnsCount; c++) { if (rnd.NextDouble() > 0.20) { grid1[r, c] = new SourceGrid.Cells.Cell(r * c, typeof(int)); } else { grid1[r, c] = null; } } } var selection = grid1.Selection as SelectionBase; for (int i = 0; i < 100; i++) { grid1[i, 0] = new Cell(i); } for (int i = 30; i < 70; i++) { grid1.Rows.ShowRow(i, false); } }
public void RangeToCellRange() { Grid grid1 = new Grid(); grid1.Redim(6, 6); grid1[0, 0] = new SourceGrid.Cells.Cell(); grid1[0, 0].ColumnSpan = 3; grid1[0, 0].RowSpan = 3; grid1[0, 3] = new SourceGrid.Cells.Cell(); grid1[0, 3].ColumnSpan = 3; grid1[0, 3].RowSpan = 3; Assert.AreEqual(new Range(0, 0, 2, 5), grid1.RangeToCellRange(new Range(0, 0, 0, 3))); }
public void CorrectSpannedCellRefShouldBeAdded() { // when we delete row, if the given row // is in the range of some cell spann, // then throw an exception Grid grid1 = new Grid(); grid1.Redim(5, 5); // add single cell at row 1, with cell span 2 grid1[1, 0] = new SourceGrid.Cells.Cell(); grid1[1, 0].RowSpan = 2; Assert.AreEqual(1, grid1.SpannedCellReferences.SpannedRangesCollection.Count); Assert.AreEqual(new Range(1, 0, 2, 0), grid1.SpannedCellReferences.SpannedRangesCollection.ToArray()[0]); }
private void ClientError(object sender, TWSClientErrorEventArgs e) { if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => ClientError(sender, e))); return; } var i = 0; logGrid.Rows.Insert(_logGridRow); logGrid[_logGridRow, i] = new SourceGrid.Cells.Cell(DateTime.Now); logGrid[_logGridRow, i].View = _defaultViewClearType; logGrid[_logGridRow, 1] = new SourceGrid.Cells.Cell(e.RequestId); logGrid[_logGridRow, 2] = new SourceGrid.Cells.Cell(e.Error.Code); logGrid[_logGridRow, 3] = new SourceGrid.Cells.Cell(e.Error.Message); }
public void GetCell() { SourceGrid.Grid grid1 = new Grid(); grid1.Redim(2, 2); Cell visibleCell = new SourceGrid.Cells.Cell("Text Span", typeof(string)); // this cell should span both to the right, and to the left grid1[0, 0] = visibleCell; grid1[0, 0].RowSpan = 2; grid1[0, 0].ColumnSpan = 2; Assert.AreEqual(visibleCell, grid1.GetCell(0, 0)); Assert.AreEqual(visibleCell, grid1.GetCell(0, 1)); Assert.AreEqual(visibleCell, grid1.GetCell(1, 0)); Assert.AreEqual(visibleCell, grid1.GetCell(1, 1)); }
public void DecreaseRowSpan_To1_ShouldRemoveIt() { // when we delete row, if the given row // is in the range of some cell spann, // then throw an exception Grid grid1 = new Grid(); grid1.Redim(5, 5); // add single cell at row 1, with cell span 2 grid1[1, 0] = new SourceGrid.Cells.Cell(); grid1[1, 0].RowSpan = 2; grid1.Rows.Remove(2); Assert.AreEqual(0, grid1.SpannedCellReferences.SpannedRangesCollection.Count); Assert.AreEqual(1, grid1[1, 0].RowSpan); }
public void Bug0002() { // the last call to change rowspan to 3 throws // exception // Could not find a spanned cell range with the same starting point as 0;3 Grid grid1 = new Grid(); grid1.Redim(1, 4); //grid1[0, 0] = new SourceGrid.Cells.Cell(); //grid1[0, 0].ColumnSpan = 3; //grid1[0, 0].RowSpan = 3; grid1[0, 3] = new SourceGrid.Cells.Cell(); grid1[0, 3].ColumnSpan = 3; grid1[0, 3].RowSpan = 3; // the bug was that there was not correctly // quadTreeNode.IsEmpty property defined }
/// <summary> /// 更新缺省活动行内容 /// </summary> protected virtual void UpdateRow(int rowIndex, ActionBase actionObject) { //缺省值 string elementValue = actionObject.DefaultValue; this[rowIndex, 2] = new SourceGrid.Cells.Cell(elementValue); //AutoWidthColumn(elementValue, rowIndex, 2); //数据绑定 ActionBase action = actionObject as ActionBase; if (!string.IsNullOrEmpty(action.MapName)) { this[rowIndex, 3] = new SourceGrid.Cells.Cell(action.MapName); AutoWidthColumn(action.MapName, rowIndex, 3); } else { this[rowIndex, 3] = new SourceGrid.Cells.Cell(""); } }
public void RemoveRowsShouldUpdateCellReferences() { // when we delete row, spanned row cells should update, // for rows, which are below our row Grid grid1 = new Grid(); grid1.Redim(5, 5); // add single cell at row 1, with cell span 2 grid1[1, 0] = new SourceGrid.Cells.Cell(); grid1[1, 0].ColumnSpan = 2; // remove row grid1.Rows.Remove(0); // add again cell at row 1 // this should not throw exception, grid1[1, 0] = new SourceGrid.Cells.Cell(); grid1[1, 0].ColumnSpan = 2; }
public void AddEmptyRow(int setNumber) { SerieCellValueChangedController serieCellValueChangedController = new SerieCellValueChangedController(this); int newRowIndex = grid1.Rows.Count; grid1.Rows.Insert(newRowIndex); var lookupEditor = new LookupEditEditor(typeof(Guid)); LookUpColumnInfo selectedCol = (LookUpColumnInfo)cmbExerciseColumns.SelectedItem; lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, ExerciseColumnIndex] = new SourceGrid.Cells.Cell(null, lookupEditor); SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, ExerciseColumnIndex].View = readOnlyView; grid1[newRowIndex, ExerciseColumnIndex].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, ExerciseColumnIndex].AddController(exerciseCellController); grid1[newRowIndex, ExerciseColumnIndex].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, ExerciseColumnIndex].Column.Width = 250; grid1[newRowIndex, CommentColumnIndex] = new SourceGrid.Cells.Cell(null, new MemoExEditEditor()); readOnlyView = new SourceGrid.Cells.Views.Cell(); //grid1[newRowIndex, 1].AddController(ee); grid1[newRowIndex, CommentColumnIndex].View = readOnlyView; grid1[newRowIndex, CommentColumnIndex].AddController(CommentableCellController); grid1[newRowIndex, CommentColumnIndex].Column.Width = 80; //string SerieRepetitionMask = string.Format(@"[0-9]*x[0-9]*[\{0}]?[0-9]*",System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); for (int i = 0; i < setNumber; i++) { //readOnlyView = new SourceGrid.Cells.Views.Cell(); var maskEditor = new SetEditor(); //maskEditor.MaskRegEx = SerieRepetitionMask; grid1[newRowIndex, StandardColumnNumber + i] = new SourceGrid.Cells.Cell(null, maskEditor); grid1[newRowIndex, StandardColumnNumber + i].AddController(serieCellValueChangedController); grid1[newRowIndex, StandardColumnNumber + i].AddController(popupMenuController); grid1[newRowIndex, StandardColumnNumber + i].View = new SetView(); } UpdateCellsReadOnlyMode(grid1.Rows[newRowIndex]); }
public void SpannedCellCreation_Performance() { // originaly this test run in ~11900 ms // after implementing this takes 1350ms :) var grid = new Grid(); var count = 10000; var columns = 500; grid.Redim(count, columns); using (var counter = new PerformanceCounter()) { for (int i = 0; i < count; i++) { grid[i, 0] = new Cell(); grid[i, 0].SetSpan(50, 500); i+=50; } Console.WriteLine("Test finished in {0} ms", counter.GetMilisec()); } }
public void ResetSelection_DoesNotInfiniteLoop() { // set up special conditions var grid = new Grid(); grid.Redim(1, 1); grid[0, 0] = new Cell(); var form = new Form(); form.Controls.Add(grid); form.Show(); grid.SelectionMode = GridSelectionMode.Row; grid.Selection.EnableMultiSelection = false; // this method causes first row to be selected. Should not fail // it failed once in RowSelection.SelectRow method // As call to ResetSelection asked to maintain focus, a stack overflow was raised grid.Selection.Focus(new Position(0, 0), false); // destroy form.Close(); form.Dispose(); }
/// <summary> /// Creates a new GridRowCellAccessibleObject /// </summary> /// <param name="cell">The grid cell</param> /// <param name="parent">The parent row of the cell</param> public GridRowCellAccessibleObject(Cell cell, GridRowAccessibleObject parent) : base() { this.cell = cell; this.parent = parent; }
private void FillFileGridRows(string[] files, bool isDir) { int r = Rows.Count; foreach (string s in files) { FileName fs = new FileName(s); Rows.Insert(r); this[r, FileIconCol] = new SourceGrid.Cells.Cell(); //ORIGINAL: this[r, FileIconCol].Image = System.Drawing.Icon.ExtractAssociatedIcon(fs.GetFilePath()).ToBitmap().GetThumbnailImage(16, 16, null, new IntPtr()); this[r, FileIconCol].Image = fileFetcher.GetIcon(fs); this[r, FileOldNameCol] = new SourceGrid.Cells.Cell(fs); this[r, FileNewNameCol] = new SourceGrid.Cells.Cell(fs.ToString(), oneClickEditor); this[r, FileNewNameCol].AddController(new ValueChangedEvent()); this[r, FileNewNameCol].Controller.OnValueChanged(new CellContext(this, new Position(r, FileNewNameCol), this[r, FileNewNameCol]), new EventArgs()); r++; } }
private Cell createOneClickCell() { Cell cell = new SourceGrid.Cells.Cell(String.Empty, oneClickEditor); return cell; }
private void frmSample17_Load(object sender, System.EventArgs e) { grid1.Redim(100, 40); grid1.FixedColumns = 0; grid1.FixedRows = 0; grid1[0,0] = new SourceGrid.Cells.Header(null); for (int c = 1; c < grid1.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader("Header " + c.ToString()); header.AutomaticSortEnabled = false; //header.ColumnSelectorEnabled = true; //header.ColumnFocusEnabled = true; grid1[0, c] = header; } Random rnd = new Random(); for (int r = 1; r < grid1.RowsCount; r++) { grid1[r,0] = new SourceGrid.Cells.RowHeader("Header " + r.ToString()); for (int c = 1; c < grid1.ColumnsCount; c++) { if (rnd.NextDouble() > 0.20) { grid1[r,c] = new SourceGrid.Cells.Cell(r*c, typeof(int)); } else grid1[r,c] = null; } } var selection = grid1.Selection as SelectionBase; for (int i = 0; i < 100; i++) grid1[i, 0] = new Cell(i); for (int i = 30; i < 70; i++) grid1.Rows.ShowRow(i, false); }
/// <summary> /// Sets up the columns and rows of the Grid. /// /// </summary> /// <returns>void</returns> private void SetupGridColumnsAndRows() { Int32 GroupHeaderCount; Int32 Counter; Int32 CurrentRow; SourceGrid.Cells.Views.Cell LabelModel; SourceGrid.Cells.Views.Cell TitleModel; String CurrentGroup; String LastGroup = ""; String LabelUse; PDataLabelRow DataLabelRow; DataColumn ForeignTableColumn; // Create class that hooks up Grid Cell Enter event notification FEnterNotificationController = new TCellEventNotificationController(); FEnterNotificationController.Initialize(this); FLabelUseDV = new DataView(FLocalDataDS.DataLabelUseList); // Create DataColumns that contain data from the DataLabel DataTable // add column: group of the data label ForeignTableColumn = new DataColumn(); ForeignTableColumn.DataType = System.Type.GetType("System.String"); ForeignTableColumn.ColumnName = "Parent_" + PDataLabelTable.GetGroupDBName(); ForeignTableColumn.Expression = "Parent." + PDataLabelTable.GetGroupDBName(); FLocalDataDS.DataLabelUseList.Columns.Add(ForeignTableColumn); // add column: is this label to be displayed ForeignTableColumn = new DataColumn(); ForeignTableColumn.DataType = System.Type.GetType("System.Boolean"); ForeignTableColumn.ColumnName = "Parent_" + PDataLabelTable.GetDisplayedDBName(); ForeignTableColumn.Expression = "Parent." + PDataLabelTable.GetDisplayedDBName(); FLocalDataDS.DataLabelUseList.Columns.Add(ForeignTableColumn); LabelUse = Enum.GetName(typeof(TOfficeSpecificDataLabelUseEnum), FOfficeSpecificDataLabelUse); // Sort by Index FLabelUseDV.Sort = PDataLabelUseTable.GetIdx1DBName() + " ASC"; // Show only Labels that should get displayed and are of the type that this UserControl is for FLabelUseDV.RowFilter = PDataLabelUseTable.GetUseDBName() + " = '" + LabelUse + "' AND Parent_" + PDataLabelTable.GetDisplayedDBName() + " = 1"; // MessageBox.Show('FLabelUseDV.RowFilter: ' + FLabelUseDV.RowFilter); // MessageBox.Show('FLabelUseDV.Count: ' + FLabelUseDV.Count.ToString); GroupHeaderCount = CalculateGroupHeaderCount(); // Set up Grid focus style // FLocalDataLabelValuesGrid.Selection.FocusStyle := SourceGrid.FocusStyle.RemoveSelectionOnLeave; // Set up Grid size FLocalDataLabelValuesGrid.Redim((FLabelUseDV.Count) + GroupHeaderCount, 3); // Initialize Size of Helper Object GridRowInfo (mapping between data and grid rows) FGridRowInfo = new TGridRowInfo(); FGridRowInfo.Initialize(FLabelUseDV.Count + GroupHeaderCount); TitleModel = new SourceGrid.Cells.Views.Cell(); TitleModel.BackColor = Color.SteelBlue; TitleModel.ForeColor = Color.White; TitleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; LabelModel = new SourceGrid.Cells.Views.Cell(); LabelModel.BackColor = FLocalDataLabelValuesGrid.BackColor; LabelModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; CurrentRow = 0; for (Counter = 0; Counter <= FLabelUseDV.Count - 1; Counter += 1) { // Find the corresponding DataLabel Row DataLabelRow = (PDataLabelRow)FLocalDataDS.DataLabelList.Rows.Find(FLabelUseDV[Counter][PDataLabelUseTable.GetDataLabelKeyDBName()]); CurrentGroup = DataLabelRow.Group; if (CurrentGroup != LastGroup) { // Create group header if Group changed FLocalDataLabelValuesGrid.Rows.SetHeight(CurrentRow, 23); FLocalDataLabelValuesGrid[CurrentRow, 0] = new SourceGrid.Cells.Cell(CurrentGroup); FLocalDataLabelValuesGrid[CurrentRow, 0].View = TitleModel; FLocalDataLabelValuesGrid[CurrentRow, 0].ColumnSpan = 3; FLocalDataLabelValuesGrid[CurrentRow, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default); CurrentRow = CurrentRow + 1; } // Create label (left of the field) FLocalDataLabelValuesGrid.Rows.SetHeight(CurrentRow, 23); FLocalDataLabelValuesGrid[CurrentRow, 0] = new SourceGrid.Cells.Cell(DataLabelRow.Text + ':'); FLocalDataLabelValuesGrid[CurrentRow, 0].View = LabelModel; FLocalDataLabelValuesGrid[CurrentRow, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default); // MessageBox.Show('Counter: ' + Counter.ToString); // MessageBox.Show('FPartnerKey: ' + FPartnerKey.ToString + '; FLocalDataDS.DataLabelList.Row[Counter].Key: ' + FLocalDataDS.DataLabelList.Row[Counter].Key.ToString); // set up the value cell(s) for the current row SetupGridValueCell(CurrentRow, DataLabelRow); // Some TODOs // Check for the p_editable_l flag and make column 1 readonly if true // should go like this: FLocalDataLabelValuesGrid[CurrentRow, 1].Editor.EnableEdit := false; // Check the value of p_char_length_i and limit the length of the editable value // see commentedout line above 'TextBoxEditor.Control.MaxLength := ' // Check the value of p_num_decimal_places_i build the corresponding format for the cell // see 'Editor' section on webpage // Implement currency (take p_currency_code_c into consideration), boolean and PartnerKey types // Implement cmbAutoComplete ComboBox (in Ict_Common_Controls.dll) for Labels where p_lookup_category_code_c is set // see file AutoTranslatedCSExampleWinForm, lines 465470 for a basic example of how to host an arbitraty control in a Cell of the Grid // MessageBox.Show('CurrentRow: ' + CurrentRow.ToString); // Hook up Grid Cell Enter event notification (for displaying Help text in the Status Bar) FLocalDataLabelValuesGrid[CurrentRow, 1].AddController(FEnterNotificationController); // Store the mapping of the current Grid Row to the PDataLabel Row that holds the Cell's Label information FGridRowInfo.SetDataRowKey(CurrentRow, (int)DataLabelRow.Key); CurrentRow = CurrentRow + 1; LastGroup = CurrentGroup; } // FLocalDataLabelValuesGrid.Columns[0].AutoSizeMode := (SourceGrid.AutoSizeMode.EnableAutoSize); or SourceGrid.AutoSizeMode.Default // FLocalDataLabelValuesGrid.Columns[1].AutoSizeMode := (SourceGrid.AutoSizeMode.EnableAutoSize); or SourceGrid.AutoSizeMode.Default // FLocalDataLabelValuesGrid.Columns[2].AutoSizeMode := (SourceGrid.AutoSizeMode.EnableAutoSize); or SourceGrid.AutoSizeMode.Default FLocalDataLabelValuesGrid.Columns[0].AutoSizeMode = (SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default); FLocalDataLabelValuesGrid.Columns[1].AutoSizeMode = (SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default); FLocalDataLabelValuesGrid.Columns[2].AutoSizeMode = (SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default); // This grid does not work the same way as our 'normal' grids, so we need to modify the keyboard handling FLocalDataLabelValuesGrid.SpecialKeys = FLocalDataLabelValuesGrid.SpecialKeys | GridSpecialKeys.SimplifiedTabEnter; // FLocalDataLabelValuesGrid.AutoSize; FLocalDataLabelValuesGrid.AutoStretchColumnsToFitWidth = true; FLocalDataLabelValuesGrid.Columns.StretchToFit(); ApplySecurity(); FGridIsSetUp = true; // set width for controls (comboboxes and buttons) ActUponGridSizeChanged(); }
/// <summary> /// Sets up the value cell(s) for a specific data label /// /// </summary> /// <returns>void</returns> private void SetupGridValueCell(Int32 ARowIndex, PDataLabelRow ADataLabelRow) { Control cellControl; System.Windows.Forms.TextBox TextBoxEditor; TtxtPetraDate DateEditor; System.Windows.Forms.CheckBox CheckBoxEditor; TTxtNumericTextBox TextBoxNumericEditor; TTxtCurrencyTextBox TextBoxCurrencyEditor; TCmbAutoPopulated LookupValueEditor; TtxtAutoPopulatedButtonLabel PartnerKeyEditor; SourceGrid.Cells.Views.Cell ValueModel; SourceGrid.Cells.Views.Cell SuffixModel; PDataLabelValuePartnerRow DataLabelValuePartnerRow; PDataLabelValueApplicationRow DataLabelValueApplicationRow; // prepare model for the value cells ValueModel = new SourceGrid.Cells.Views.Cell(); ValueModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft; ValueModel.Font = new Font(FLocalDataLabelValuesGrid.Font.FontFamily.Name, FLocalDataLabelValuesGrid.Font.Size, FontStyle.Bold); // prepare model for suffix cells (e.g. for currency) SuffixModel = new SourceGrid.Cells.Views.Cell(); SuffixModel.BackColor = FLocalDataLabelValuesGrid.BackColor; SuffixModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft; // In this case the data value rows will only be created once a value is entered GetOrCreateDataLabelValueRow(false, ADataLabelRow, out DataLabelValuePartnerRow, out DataLabelValueApplicationRow); // initialize cell control cellControl = null; // Create field, according to specified data type // Create character field if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_CHAR) { TextBoxEditor = new System.Windows.Forms.TextBox(); cellControl = TextBoxEditor; if (DataLabelValuePartnerRow != null) { TextBoxEditor.Text = DataLabelValuePartnerRow.ValueChar; } else if (DataLabelValueApplicationRow != null) { TextBoxEditor.Text = DataLabelValueApplicationRow.ValueChar; } else { // Default value if no Label data exists for the Partner TextBoxEditor.Text = ""; } // enable save button in editor when cell contents have changed TextBoxEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxEditor; } // Create float field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_FLOAT) { TextBoxNumericEditor = new TTxtNumericTextBox(); if (ADataLabelRow.NumDecimalPlaces == 0) { TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.LongInteger; TextBoxNumericEditor.MaxLength = 14; } else { TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Decimal; TextBoxNumericEditor.DecimalPlaces = ADataLabelRow.NumDecimalPlaces; // limit text length. 14 for number of digits, 5 for decimal and thousands separators TextBoxNumericEditor.MaxLength = 14 + 5 + ADataLabelRow.NumDecimalPlaces; } TextBoxNumericEditor.NullValueAllowed = true; cellControl = TextBoxNumericEditor; if (ADataLabelRow.NumDecimalPlaces == 0) { if (DataLabelValuePartnerRow != null) { TextBoxNumericEditor.NumberValueLongInt = (long)DataLabelValuePartnerRow.ValueNum; } else if (DataLabelValueApplicationRow != null) { TextBoxNumericEditor.NumberValueLongInt = (long)DataLabelValueApplicationRow.ValueNum; } else { // Default value if no Label data exists for the Partner TextBoxNumericEditor.NumberValueLongInt = null; } } else { if (DataLabelValuePartnerRow != null) { TextBoxNumericEditor.NumberValueDecimal = DataLabelValuePartnerRow.ValueNum; } else if (DataLabelValueApplicationRow != null) { TextBoxNumericEditor.NumberValueDecimal = DataLabelValueApplicationRow.ValueNum; } else { // Default value if no Label data exists for the Partner TextBoxNumericEditor.NumberValueDecimal = null; } } // enable save button in editor when cell contents have changed TextBoxNumericEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxNumericEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxNumericEditor; } // Create data field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_DATE) { DateEditor = new TtxtPetraDate(); DateEditor.Date = null; cellControl = DateEditor; if (DataLabelValuePartnerRow != null) { if (!DataLabelValuePartnerRow.IsValueDateNull()) { DateEditor.Date = DataLabelValuePartnerRow.ValueDate; } } else if (DataLabelValueApplicationRow != null) { if (!DataLabelValueApplicationRow.IsValueDateNull()) { DateEditor.Date = DataLabelValueApplicationRow.ValueDate; } } // enable save button in editor when cell contents have changed DateEditor.DateChanged += new TPetraDateChangedEventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)DateEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = DateEditor; } // Create integer field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_INTEGER) { TextBoxNumericEditor = new TTxtNumericTextBox(); TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Integer; TextBoxNumericEditor.NullValueAllowed = true; cellControl = TextBoxNumericEditor; if (DataLabelValuePartnerRow != null) { TextBoxNumericEditor.NumberValueInt = DataLabelValuePartnerRow.ValueInt; } else if (DataLabelValueApplicationRow != null) { TextBoxNumericEditor.NumberValueInt = DataLabelValueApplicationRow.ValueInt; } else { // Default value if no Label data exists for the Partner TextBoxNumericEditor.NumberValueInt = null; } // enable save button in editor when cell contents have changed TextBoxNumericEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxNumericEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxNumericEditor; } // Create currency field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_CURRENCY) { TextBoxCurrencyEditor = new TTxtCurrencyTextBox(); TextBoxCurrencyEditor.DecimalPlaces = 2; TextBoxCurrencyEditor.CurrencyCode = ADataLabelRow.CurrencyCode; TextBoxCurrencyEditor.NullValueAllowed = true; cellControl = TextBoxCurrencyEditor; if (DataLabelValuePartnerRow != null) { TextBoxCurrencyEditor.NumberValueDecimal = DataLabelValuePartnerRow.ValueCurrency; } else if (DataLabelValueApplicationRow != null) { TextBoxCurrencyEditor.NumberValueDecimal = DataLabelValueApplicationRow.ValueCurrency; } else { // Default value if no Label data exists for the Partner TextBoxCurrencyEditor.NumberValueDecimal = null; } // enable save button in editor when cell contents have changed TextBoxCurrencyEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxCurrencyEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxCurrencyEditor; } // Create boolean field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_BOOLEAN) { CheckBoxEditor = new System.Windows.Forms.CheckBox(); cellControl = CheckBoxEditor; if (DataLabelValuePartnerRow != null) { CheckBoxEditor.Checked = DataLabelValuePartnerRow.ValueBool; } else if (DataLabelValueApplicationRow != null) { CheckBoxEditor.Checked = DataLabelValueApplicationRow.ValueBool; } else { // Default value if no Label data exists for the Partner CheckBoxEditor.Checked = false; } // enable save button in editor when cell contents have changed CheckBoxEditor.CheckedChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)CheckBoxEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = CheckBoxEditor; } // Create partner key field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_PARTNERKEY) { PartnerKeyEditor = new TtxtAutoPopulatedButtonLabel(); PartnerKeyEditor.ASpecialSetting = true; PartnerKeyEditor.ButtonText = ADataLabelRow.Text + ':'; PartnerKeyEditor.ButtonTextAlign = System.Drawing.ContentAlignment.MiddleRight; PartnerKeyEditor.ListTable = TtxtAutoPopulatedButtonLabel.TListTableEnum.PartnerKey; PartnerKeyEditor.TabStop = false; cellControl = PartnerKeyEditor; // AutomaticallyUpdateDataSource: very rare, but needed here PartnerKeyEditor.AutomaticallyUpdateDataSource = true; if (DataLabelValuePartnerRow != null) { PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(DataLabelValuePartnerRow.ValuePartnerKey); } else if (DataLabelValueApplicationRow != null) { PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(DataLabelValueApplicationRow.ValuePartnerKey); } else { // Default value if no Label data exists for the Partner PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(0); } // display partner name linked to partner key PartnerKeyEditor.ResetLabelText(); // enable save button in editor when cell contents have changed PartnerKeyEditor.ValueChanged += new TDelegatePartnerChanged(this.PartnerKeyControlValueHasChanged); PartnerKeyEditor.TextChanged += new System.EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 0] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue(PartnerKeyEditor, new Position(ARowIndex, 0))); FLocalDataLabelValuesGrid[ARowIndex, 0].Tag = PartnerKeyEditor; FLocalDataLabelValuesGrid[ARowIndex, 0].ColumnSpan = 3; } // Create lookup field else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_LOOKUP) { // Get the instance of the combobox (created in the actual user interface class) LookupValueEditor = new TCmbAutoPopulated(); LookupValueEditor.Filter = PDataLabelLookupTable.GetCategoryCodeDBName() + " = '" + ADataLabelRow.LookupCategoryCode + "'"; LookupValueEditor.ListTable = TCmbAutoPopulated.TListTableEnum.DataLabelLookupList; LookupValueEditor.InitialiseUserControl(); cellControl = LookupValueEditor; if (DataLabelValuePartnerRow != null) { LookupValueEditor.SetSelectedString(DataLabelValuePartnerRow.ValueLookup); } else if (DataLabelValueApplicationRow != null) { LookupValueEditor.SetSelectedString(DataLabelValueApplicationRow.ValueLookup); } else { // Default value if no Label data exists for the Partner LookupValueEditor.Text = ""; } // enable save button in editor when cell contents have changed LookupValueEditor.SelectedValueChanged += new EventHandler(this.ControlValueHasChanged); LookupValueEditor.TextChanged += new EventHandler(this.ControlValueHasChanged); FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell(); FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)LookupValueEditor, new Position(ARowIndex, 1))); FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = LookupValueEditor; FLocalDataLabelValuesGrid[ARowIndex, 1].ColumnSpan = 2; } // perform actions that need to be done for each control if (cellControl != null) { // remember the added control to get the value back lateron FGridRowInfo.SetControl(ARowIndex, cellControl); // handle focus change when field is entered cellControl.Enter += new EventHandler(this.UpdateGridFocusFromExternalControl); // set help text for control PetraUtilsObject.SetStatusBarText(cellControl, ADataLabelRow.Description); } // check if value is editable if (!ADataLabelRow.Editable) { FLocalDataLabelValuesGrid[ARowIndex, 1].Editor.EnableEdit = false; } }
public void AreSpannedCells_CorrectlyRemoved() { SourceGrid.Grid grid1 = new Grid(); grid1.Redim(2, 2); grid1[0, 0] = new Cell(); grid1[0, 0].ColumnSpan = 2; grid1[0, 0] = null; // this should be true. But is not, at the moment of writing Assert.AreEqual(null, grid1.GetCell(0, 1)); // this should not throw exception grid1[0, 1] = new Cell("my new cell"); }
private void PopulateCell(int p_GridRow, int p_GridCol, System.Reflection.PropertyInfo p_PropInfo, Cells.Editors.EditorBase p_Editor, object p_Object) { grid[p_GridRow, p_GridCol] = new Cells.Cell(p_PropInfo.GetValue(p_Object,null)); grid[p_GridRow, p_GridCol].Editor = p_Editor; Cells.Controllers.BindProperty l_Bind = new Cells.Controllers.BindProperty(p_PropInfo, p_Object); grid[p_GridRow, p_GridCol].AddController(l_Bind); Cells.Controllers.CustomEvents l_CustomEvents = new Cells.Controllers.CustomEvents(); l_CustomEvents.ValueChanged += new EventHandler(Grid_ValueChanged); grid[p_GridRow, p_GridCol].AddController(l_CustomEvents); }
public void Bug0001() { var grid1 = new Grid(); grid1.Redim(4, 12); grid1.FixedRows = 2; grid1[0, 3] = new Cell("5 Column Header"); grid1[0, 3].ColumnSpan = 5; //2 Header Row grid1[1, 0] = new Cell("1"); grid1[1, 1] = new Cell("2"); var cell = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false); grid1[2, 2] = cell; grid1[2, 2].ColumnSpan = 2; grid1[2, 2].RowSpan = 2; // test that all cells point to the same cell Assert.AreEqual(cell, grid1.GetCell(2, 3)); Assert.AreEqual(cell, grid1.GetCell(3, 2)); Assert.AreEqual(cell, grid1.GetCell(3, 3)); }
private void CreateGrid() { IrssLog.Info("Creating configuration grid ..."); try { int row = 0; gridPlugins.Rows.Clear(); gridPlugins.Columns.SetCount(5); // Setup Column Headers gridPlugins.Rows.Insert(row); ColumnHeader header = new ColumnHeader(" "); header.AutomaticSortEnabled = false; gridPlugins[row, ColIcon] = header; gridPlugins[row, ColName] = new ColumnHeader("Name"); gridPlugins[row, ColReceive] = new ColumnHeader("Receive"); gridPlugins[row, ColTransmit] = new ColumnHeader("Transmit"); gridPlugins[row, ColConfigure] = new ColumnHeader("Configure"); gridPlugins.FixedRows = 1; foreach (PluginBase transceiver in _transceivers) { gridPlugins.Rows.Insert(++row); gridPlugins.Rows[row].Tag = transceiver; // Icon Cell if (transceiver.DeviceIcon != null) { Image iconCell = new Image(transceiver.DeviceIcon); iconCell.Editor.EnableEdit = false; gridPlugins[row, ColIcon] = iconCell; } else { gridPlugins[row, ColIcon] = new Cell(); } // Name Cell Cell nameCell = new Cell(transceiver.Name); CustomEvents nameCellController = new CustomEvents(); nameCellController.DoubleClick += PluginDoubleClick; nameCell.AddController(nameCellController); nameCell.AddController(new ToolTipText()); nameCell.ToolTipText = String.Format("{0}\nVersion: {1}\nAuthor: {2}\n{3}", transceiver.Name, transceiver.Version, transceiver.Author, transceiver.Description); gridPlugins[row, ColName] = nameCell; // Receive Cell if (transceiver is IRemoteReceiver || transceiver is IMouseReceiver || transceiver is IKeyboardReceiver) { gridPlugins[row, ColReceive] = new CheckBox(); } else { gridPlugins[row, ColReceive] = new Cell(); } // Transmit Cell if (transceiver is ITransmitIR) { CheckBox checkbox = new CheckBox(); CustomEvents checkboxcontroller = new CustomEvents(); checkboxcontroller.ValueChanged += TransmitChanged; checkbox.Controller.AddController(checkboxcontroller); gridPlugins[row, ColTransmit] = checkbox; } else { gridPlugins[row, ColTransmit] = new Cell(); } // Configure Cell if (transceiver is IConfigure) { Button button = new Button("Configure"); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += buttonClickEvent_Executed; button.Controller.AddController(buttonClickEvent); gridPlugins[row, ColConfigure] = button; } else { gridPlugins[row, ColConfigure] = new Cell(); } } gridPlugins.Columns[ColIcon].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; gridPlugins.Columns[ColName].AutoSizeMode = SourceGrid.AutoSizeMode.Default; gridPlugins.Columns[ColReceive].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; gridPlugins.Columns[ColTransmit].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; gridPlugins.Columns[ColConfigure].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; gridPlugins.AutoStretchColumnsToFitWidth = true; gridPlugins.AutoSizeCells(); gridPlugins.SortRangeRows(new RangeFullGridNoFixedRows(), ColName, true, new ValueCellComparer()); } catch (Exception ex) { IrssLog.Error(ex); MessageBox.Show(this, ex.ToString(), "Error setting up plugin grid", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SetColumnsAndRows(string[] columns, string[] rows, Grid grid) { if (grid.InvokeRequired) { SetNumberOfColumnsAndRows d = SetColumnsAndRows; Invoke(d, columns, rows, grid); } else { grid.Rows.Clear(); grid.Columns.Clear(); grid.Rows.Insert(0); grid.Columns.Insert(0); for (int row = 1; row <= rows.Length; row++) { grid.Rows.Insert(row); grid[row, 0] = new RowHeader(rows[row - 1]); for (int column = 1; column <= columns.Length; column++) { if (row == 1) { grid.Columns.Insert(column); grid[0, column] = new SourceGrid.Cells.ColumnHeader(columns[column - 1]); } grid[row, column] = new Cell(); grid[row, column].View = new SourceGrid.Cells.Views.Cell(); } } grid.AutoSizeCells(); } }