Index was out of range. Must be non-negative and less than the size of the collection.

  • Thread starter Thread starter engahmedbarbary
  • Start date Start date
E

engahmedbarbary

Guest
Problem

The Problem:

Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index



Problem Location:

Forms.DataForm.Dispose(Boolean disposing) in D:\TFSServerCollection\Module \Code\Forms\Forms\DataForm.designer.cs:line 23

error on line 23 base.dispose(disposing);

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}

try
{
base.Dispose(disposing); line 23
}
catch(System.ArgumentOutOfRangeException ex)
{
xExceptions.ShowExceptionInfo(ex);
}
}

code that make this error

public static void frm_Closing(object sender, FormClosingEventArgs e)
{
if (e.Cancel == true) return;

xForm frm = sender as xForm;

if (!frm.StopSaveGridColumnsWidth) xLayout.SaveGridColumnsWidth(frm.Controls);
MenuManager.RemoveFromActiveWindowsMenu(frm);
GlobalVariables.ActiveFormName = "";
GlobalVariables.ActiveFormID = -1;


if (SqlFactory.FormsData.Keys.Contains(frm.TableName))
{
SqlFactory.FormsData.Remove(frm.TableName);
}

ApplicationOpenForms.RemoveForm(frm.Name);
}here error generated

After line ApplicationOpenForms.RemoveForm(frm.Name);

error generated

function removeform

public static void RemoveForm(string FormName)
{
if (IsExist(FormName))
{
int count = 0;
for (int i = 0; i < Application.OpenForms.Count; i++)
{
if (Application.OpenForms.Name == FormName)
{
count += 1;
}
}
if (count == 1)
Forms.Remove(FormName);
}
}

Continue reading...
 
Back
Top