Code example:
- Code: Select all
public void SelectForm(Guid guid)
{
if (forms.ContainsKey(guid))
{
KryptonPage tabPage = forms[guid].TabPage;
if (tabPage == null)
{
FormBase form = CreateFormInstance(forms[guid]);
if (form != null)
{
tabPage = CreateTabItem(form);
}
else return;
}
if (tabPage != null)
{
forms[guid].TabPage = tabPage;
if (!tabControl.Pages.Contains(tabPage))
{
tabControl.Pages.Add(tabPage);
}
tabControl.SelectedPage = tabPage;
}
}
}
In the treeview mouseclick event I call this method. The problem is, when I click too fast I get the following exception on the tabControl.Pages.Add(tabPage);
De index moet binnen de grenzen van de lijst liggen.
Parameternaam: index, bij System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
bij System.Collections.Generic.List`1.Insert(Int32 index, T item)
bij ComponentFactory.Krypton.Toolkit.ViewComposite.Insert(Int32 index, ViewBase item)
bij dr.a(Object A_0, TypedCollectionEventArgs`1 A_1)
bij ComponentFactory.Krypton.Toolkit.TypedHandler`1.Invoke(Object sender, TypedCollectionEventArgs`1 e)
bij ComponentFactory.Krypton.Toolkit.TypedCollection`1.OnInserted(TypedCollectionEventArgs`1 e)
bij ComponentFactory.Krypton.Toolkit.TypedCollection`1.Add(T item)
bij Pits.Forms.Base.DockingBase.SelectForm(Guid guid) in D:\Project\Edumar_pits\PITS\Pits\Forms\Base\DockingBase.cs:regel 166
Is there a way to prevent this?
Regards,
Joost