Handle MyStepRTB Dispose

Fixed a NullReference Bug
This commit is contained in:
Rich 2011-02-11 21:14:08 +00:00
parent 0ad442ae19
commit 2876ad911a
2 changed files with 13 additions and 2 deletions

View File

@ -157,7 +157,11 @@ namespace Volian.Controls.Library
_MyItemInfo = args.MyItemInfo;
_MyEditItem = args.MyEditItem;
if (_MyEditItem != null)
{
_MyStepRTB = _MyEditItem.MyStepRTB;
if(_MyStepRTB != null)
_MyStepRTB.Disposed += new EventHandler(_MyStepRTB_Disposed);
}
else
_MyStepRTB = null;
}
@ -169,6 +173,10 @@ namespace Volian.Controls.Library
}
if (ItemSelectedChanged != null) ItemSelectedChanged(sender, args);
}
void _MyStepRTB_Disposed(object sender, EventArgs e)
{
_MyStepRTB = null;
}
public event StepPanelModeChangeEvent ModeChange;
internal void OnModeChange(object sender, StepRTBModeChangeEventArgs args)
{

View File

@ -215,8 +215,11 @@ namespace Volian.Controls.Library
private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore
void MyFlexGrid_SelChange(object sender, EventArgs e)
{
if (MyFlexGrid.Selection.IsSingleCell && MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0)
_OrigRtf = MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col].ToString();
if (MyFlexGrid.Selection.IsSingleCell && MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0)
{
object obj = MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col];
_OrigRtf = obj == null ? string.Empty : obj.ToString();
}
}
void MyStepRTB_KeyDown(object sender, KeyEventArgs e)
{