Skip to content
Browse files

WinForms: Check for null for TabControl.SelectedIndex

WinForms: Handle NRE when removing tab page from tab control
  • Loading branch information...
1 parent a3c2ac4 commit 1f488396b288c6f2c0309252fe5b69307d08f999 @cwensley cwensley committed
View
7 Source/Eto.Platform.Mac/Forms/Controls/TabControlHandler.cs
@@ -25,11 +25,12 @@ public TabControlHandler ()
#region ITabControl Members
- public int SelectedIndex {
- get { return Control.IndexOf (Control.Selected); }
+ public int SelectedIndex
+ {
+ get { return Control.Selected != null ? Control.IndexOf(Control.Selected) : -1; }
set { Control.SelectAt (value); }
}
-
+
public override bool Enabled {
get; set;
}
View
2 Source/Eto.Platform.Windows/Forms/Controls/TabPageHandler.cs
@@ -56,7 +56,7 @@ void SetImage ()
public override void SetParent (Control parent)
{
base.SetParent (parent);
- tabcontrol = parent.ControlObject as SWF.TabControl;
+ tabcontrol = parent != null ? parent.ControlObject as SWF.TabControl : null;
SetImage ();
}

0 comments on commit 1f48839

Please sign in to comment.
Something went wrong with that request. Please try again.