![]() |
| | #1 |
| Registered User Join Date: Nov 2008
Posts: 32
| 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; |
| leo2008 is offline | |
| | #2 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| Then I'd guess that e.ItemIndex is either negative, or larger than aChkBoxArray.Length. Neither is good. Debug it.
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Screwy Linker Error - VC2005 | Tonto | C++ Programming | 5 | 06-19-2007 02:39 PM |
| Unhandled exception on Stream variable for HttpWebRequest/HttpWebResponse | BobS0327 | C# Programming | 3 | 11-11-2006 06:46 PM |
| Unhandled exception error in VC++ | tandirovic | Windows Programming | 2 | 12-29-2005 05:16 PM |
| unhandled exception error | trends | C++ Programming | 4 | 11-15-2002 06:54 PM |
| Unhandled Exception | StringQuartet13 | C++ Programming | 1 | 03-04-2002 05:18 PM |