|
-
December 14th, 2008, 10:07 AM
#1
Listview control exception
Hi everyone,
I hope someone can help me with this as I was unable to find anything on my own.
I have a C# very basic GUI application with 2 buttons and a listview control.
The listview control is being populated by a thread that is started from an external c++ dll I made myself. I pass the handle to the DLL function and I add items this way :
LVITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = 0;
lvItem.iSubItem = 0;
lvItem.pszText = "Just another entry";
lvItem.iItem = (int) SendMessage( hList, LVM_GETITEMCOUNT, 0, 0);
SendMessage( hList, LVM_INSERTITEM, 0, (LPARAM) &lvItem);
This works fine and the listview gets populated with no errors.
However if I give focus to the listview and maybe select different items or take the focus away I receive the following Exception :
************** Exception Text **************
System.ArgumentOutOfRangeException: InvalidArgument=Value of '2' is not valid for 'index'.
Parameter name: index
at System.Windows.Forms.ListView.ListViewItemCollection.get_Item(Int32 index)
at System.Windows.Forms.ListView.get_FocusedItem()
at System.Windows.Forms.ListView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
HTTPLister
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/Code/HTTPLister/HTTPLister/bin/Release/HTTPLister.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
I do not have any code related to the the listview control on the C# side so I assume everything is handled by the default proc for the control.
I could really use some help with this.
Thanks in advance
-
December 14th, 2008, 06:45 PM
#2
Re: Listview control exception
It's hard to answer without seeing an of the code that is actually causing the error. Have you stepped through the code and found the line which is throwing the exception.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|