diff --git a/PROMS/Volian.Controls.Library/VlnBorders.cs b/PROMS/Volian.Controls.Library/VlnBorders.cs index 56d1144e..41582d62 100644 --- a/PROMS/Volian.Controls.Library/VlnBorders.cs +++ b/PROMS/Volian.Controls.Library/VlnBorders.cs @@ -243,6 +243,16 @@ namespace Volian.Controls.Library return pn; } #endregion +#region checkborderarrays + // C2018-031 Adjust the Horizontal and Vertical cell border arrays if needed + public void CheckAndFixBorderArraySize(int grdRows, int grdCols, GridLinePattern defaultLinePattern) + { + if (HorizontalLines.Columns != grdCols || HorizontalLines.Rows != grdRows + 1) + HorizontalLines = new LinePatternArray(defaultLinePattern, grdRows + 1, grdCols, HorizontalLines.Lines); + if (VerticalLines.Columns != grdCols + 1 || VerticalLines.Rows != grdRows) + VerticalLines = new LinePatternArray(defaultLinePattern, grdRows, grdCols + 1, VerticalLines.Lines); + } +#endregion } [Serializable] public class LinePatternArray @@ -281,6 +291,22 @@ namespace Volian.Controls.Library for (int c = 0; c < Columns; c++) Lines[r * Columns + c] = defaultLinePattern; } + // C2018-031 used to automatically adjust the cell border arrays + public LinePatternArray(GridLinePattern defaultLinePattern, int rows, int columns, GridLinePattern[] lnsAry) + { + Rows = rows; + Columns = columns; + Lines = new GridLinePattern[rows * columns]; + for (int r = 0; r < Rows; r++) + for (int c = 0; c < Columns; c++) + { + int idx = r * Columns + c; + if (idx < lnsAry.Length) + Lines[idx] = lnsAry[idx]; + else + Lines[idx] = defaultLinePattern; + } + } #endregion #region Array Access public GridLinePattern this[int r, int c] @@ -289,7 +315,7 @@ namespace Volian.Controls.Library { int indx = r * Columns + c; if (indx < Lines.Length) return Lines[r * Columns + c]; - _MyLog.WarnFormat("GridLinePattern: Lines Array Access out-of-bounds ({0}, {1}) within ({2}, {3})", r, c, Rows, Columns); + _MyLog.WarnFormat("GridLinePattern: Lines Array Access out-of-bounds ({0}, {1}) within ({2}, {3})", r, c, Rows, Columns); return GridLinePattern.Single; } set { Lines[r * Columns + c] = value; } diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index 6622d542..ee4db5c8 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -1356,6 +1356,7 @@ namespace Volian.Controls.Library Rectangle bounds = e.Bounds; int row = e.Row; int col = e.Col; + MyBorders.CheckAndFixBorderArraySize(this.Rows.Count, this.Cols.Count, GridLinePattern.Single); // C2018-031 check the cell border arrays CellRange cr = GetMergedRange(row, col); GridLinePattern topSide = MyBorders.HorizontalLines[cr.r1,cr.c1]; GridLinePattern rightOfTopSide = cr.c2 == Cols.Count - 1 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r1, cr.c2 + 1];