Added Error Handler for corrupted table data.

This commit is contained in:
Rich
2014-10-22 20:25:31 +00:00
parent 6098140d26
commit 505bfa467d
2 changed files with 23 additions and 8 deletions

View File

@@ -759,10 +759,17 @@ namespace Volian.Controls.Library
Focus(); Focus();
MyFlexGrid.Focus(); MyFlexGrid.Focus();
if (!MyFlexGrid.IsRoTable) // Table ROs are none editable - don't select a table cell if (!MyFlexGrid.IsRoTable) // Table ROs are none editable - don't select a table cell
{
try
{ {
MyFlexGrid.Select(0, 0); MyFlexGrid.Select(0, 0);
MyFlexGrid.FirstEntry = true; // to fix a problem with initial mouse click into table MyFlexGrid.FirstEntry = true; // to fix a problem with initial mouse click into table
} }
catch (Exception ex)
{
MessageBox.Show("The content of this table is corrupted. You will either need to restore a previous version or delete it.", "Table Corrupted", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
} }
else else
{ {

View File

@@ -58,6 +58,7 @@ namespace Volian.Controls.Library
public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
@@ -892,6 +893,8 @@ namespace Volian.Controls.Library
// - set Visible back to true. // - set Visible back to true.
Visible = false; Visible = false;
if (Parent is GridItem) if (Parent is GridItem)
{
try
{ {
System.Drawing.Image img = this.CreateImage(); System.Drawing.Image img = this.CreateImage();
using (Graphics gr = (Parent as GridItem).CreateGraphics()) using (Graphics gr = (Parent as GridItem).CreateGraphics())
@@ -899,6 +902,11 @@ namespace Volian.Controls.Library
gr.DrawImage(img, Left, Top); gr.DrawImage(img, Left, Top);
} }
} }
catch (Exception ex)
{
_MyLog.WarnFormat("Table Content Corrupted");
}
}
Clear(); Clear();
MergedRanges.Clear(); MergedRanges.Clear();
_ReadingXml = true; _ReadingXml = true;