From 08b0b27c64b9ff20074f5a77a37118d65afca140 Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 19 Dec 2013 22:29:02 +0000 Subject: [PATCH] Fixed FlexGrid glitch that was causing the Column Count to be missing. The code has been changed so that the glitch will not cause a failure. --- PROMS/Volian.Controls.Library/VlnFlexGrid.cs | 38 ++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index 4c5e547b..0ea2467a 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -146,8 +146,8 @@ namespace Volian.Controls.Library { string defCW = xd.SelectSingleNode("C1FlexGrid/ColumnInfo/DefaultSize").InnerText; string defRH = xd.SelectSingleNode("C1FlexGrid/RowInfo/DefaultSize").InnerText; - int cols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText); - int rows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText); + int cols = ColumnCount(xd); + int rows = RowCount(xd); List rh = new List(); for (int i = 0; i < rows; i++) rh.Add(defRH); @@ -182,10 +182,36 @@ namespace Volian.Controls.Library } return rhcw; } + private int ColumnCount(XmlDocument xd) + { + XmlNode xn = xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count"); + int cols = 0; + if (xn != null) + cols = int.Parse(xn.InnerText); + else + { + XmlNodeList nl = xd.SelectNodes("C1FlexGrid/Columns/Column"); + cols = nl.Count; + } + return cols; + } + private int RowCount(XmlDocument xd) + { + XmlNode xn = xd.SelectSingleNode("C1FlexGrid/RowInfo/Count"); + int rows = 0; + if (xn != null) + rows = int.Parse(xn.InnerText); + else + { + XmlNodeList nl = xd.SelectNodes("C1FlexGrid/Rows/Row"); + rows = nl.Count; + } + return rows; + } private string GetCellDataString(XmlDocument xd) { - int cols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText); - int rows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText); + int cols = ColumnCount(xd); + int rows = RowCount(xd); List datum = new List(); for (int i = 0; i < rows * cols; i++) datum.Add("|"); @@ -208,8 +234,8 @@ namespace Volian.Controls.Library } private string GetCellFormatString(XmlDocument xd) { - int cols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText); - int rows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText); + int cols = ColumnCount(xd); + int rows = RowCount(xd); List datum = new List(); for (int i = 0; i < rows * cols; i++) datum.Add("|");