hi all
Argument OutOfRangeException was unhandled by user code
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Code:
if (cChkBoxState == CheckBoxState.CheckedNormal)
{
string nodeFullPath = nodePath(this.tvFolders.SelectedNode.FullPath.ToString());
ListViewItem selectedItem = new ListViewItem();
selectedItem = e.Item;
string keyType = selectedItem.SubItems[1].Text.ToString();
InitListView(this.tvFolders.SelectedNode);
if ("STRING" == keyType)
{
ManagedRegItemString attributeRegItem = new ManagedRegItemString();
string stringVal = selectedItem.SubItems[2].Text.ToString();
attributeRegItem.stringValue = stringVal;
attributeRegItem.name = selectedItem.Text;
attributeRegItem.attributes = RegItemAttributeEnum.RegItemAttrReadonly;
ManagedRegistry.Delete(nodeFullPath, selectedItem.Text);
ManagedRegistry.WriteItem(nodeFullPath, attributeRegItem);
}
if ("INTEGER" == keyType)
{
ManagedRegItemInteger attributeRegItem = new ManagedRegItemInteger();
string intVal = selectedItem.SubItems[2].Text.ToString();
int integerVal = (int)Convert.ToInt32(intVal);
attributeRegItem.integerValue = integerVal ;
attributeRegItem.name = selectedItem.Text;
attributeRegItem.attributes = RegItemAttributeEnum.RegItemAttrReadonly;
ManagedRegistry.Delete(nodeFullPath, selectedItem.Text);
ManagedRegistry.WriteItem(nodeFullPath, attributeRegItem);
}
if ("BINARY" == keyType)
{
ManagedRegItemBinary attributeRegItem = new ManagedRegItemBinary();
string binVal = selectedItem.SubItems[2].Text.ToString();
byte [] binaryVal = new byte[10];
for(int i = 0; i < 10; i++)
{
binaryVal = System.Text.UTF8Encoding.ASCII.GetBytes(binVal);
}
attributeRegItem.binaryValue = binaryVal;
attributeRegItem.name = selectedItem.Text;
attributeRegItem.attributes = RegItemAttributeEnum.RegItemAttrReadonly;
ManagedRegistry.WriteItem(nodeFullPath, attributeRegItem);
}
// Delete and write the updated value to the database
InitListView(this.tvFolders.SelectedNode);
EnumerateHBRegNode(this.tvFolders.SelectedNode);
this.lvFiles.Refresh();
}
((CustomCheckBox)aChkBoxArray[e.ItemIndex]).bStateChanged = false;
}
the exception occurs at this line below:
((CustomCheckBox)aChkBoxArray[e.ItemIndex]).bStateChanged = false;