473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

unhandled exeption in ListView

I have a ListView that contains the subfoldes of a local drive.
Whan i click on a subfolder the listbox should display the subfolders of
this folder instead.
the funktion is as follows:
private void FolderList_SelectedIndexChanged(object sender, System.EventArgs
e)

{

try

{

ListView.SelectedListViewItemCollection SelectedDir =
this.FolderList.SelectedItems;

foreach ( ListViewItem Dir in SelectedDir )

{

FolderList.Items.Clear();

foreach (string d in Directory.GetDirectories(Dir.Text))

{

FolderList.Items.Add(d);

}

}

}

catch

{

MessageBox.Show("Error entering directory","Error",MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);

}

}

*
Now when i try to access the folder "System Volume Information" I first get
my MessageBox and then a messagebox saying that I have an unhandled
exeption.
But the funny thing is that I only get this message in the release version.
Can annyboddy tel me what I do rong?

The exeption text is as follows:

************** Exception Text **************
System.ArgumentOutOfRangeException: Specified argument was out of the range
of valid values.
Parameter name: '5' is not a valid value for 'displayIndex'.
at System.Windows.Forms.ListViewItemCollection.get_It em(Int32
displayIndex)
at System.Windows.Forms.ListView.LvnBeginDrag(MouseBu ttons buttons,
NMLISTVIEW nmlv)
at System.Windows.Forms.ListView.WmReflectNotify(Mess age& m)
at System.Windows.Forms.ListView.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
Nov 16 '05 #1
2 3349
1. System volume information is a system folder for which you don't have
access.
2. You're clearing all items on selection change (which may not make for the
best user experience). What happens is when you click on a list view item,
one event that happens is the selection change. The other event that
happens is BeginDrag. However, by the time BeginDrag event got processed,
all the items in the listview have been deleted and that's why the BeginDrag
event throws an ArgumentException (because it's expecting the drag item to
be still there).

You might want to rethink your design.

-vJ

"Aron Henning" <ar**@longhorn.com> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
I have a ListView that contains the subfoldes of a local drive.
Whan i click on a subfolder the listbox should display the subfolders of
this folder instead.
the funktion is as follows:
private void FolderList_SelectedIndexChanged(object sender,
System.EventArgs
e)

{

try

{

ListView.SelectedListViewItemCollection SelectedDir =
this.FolderList.SelectedItems;

foreach ( ListViewItem Dir in SelectedDir )

{

FolderList.Items.Clear();

foreach (string d in Directory.GetDirectories(Dir.Text))

{

FolderList.Items.Add(d);

}

}

}

catch

{

MessageBox.Show("Error entering directory","Error",MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);

}

}

*
Now when i try to access the folder "System Volume Information" I first
get
my MessageBox and then a messagebox saying that I have an unhandled
exeption.
But the funny thing is that I only get this message in the release
version.
Can annyboddy tel me what I do rong?

The exeption text is as follows:

************** Exception Text **************
System.ArgumentOutOfRangeException: Specified argument was out of the
range
of valid values.
Parameter name: '5' is not a valid value for 'displayIndex'.
at System.Windows.Forms.ListViewItemCollection.get_It em(Int32
displayIndex)
at System.Windows.Forms.ListView.LvnBeginDrag(MouseBu ttons buttons,
NMLISTVIEW nmlv)
at System.Windows.Forms.ListView.WmReflectNotify(Mess age& m)
at System.Windows.Forms.ListView.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Nov 16 '05 #2
I need the hole list to be deleted. Btw, a guy at www.codeproject.com gave
me a working solution.

"Vijaye Raji" <no*************@hotmail.com> skrev i en meddelelse
news:%2****************@TK2MSFTNGP12.phx.gbl...
| 1. System volume information is a system folder for which you don't have
| access.
| 2. You're clearing all items on selection change (which may not make for
the
| best user experience). What happens is when you click on a list view
item,
| one event that happens is the selection change. The other event that
| happens is BeginDrag. However, by the time BeginDrag event got processed,
| all the items in the listview have been deleted and that's why the
BeginDrag
| event throws an ArgumentException (because it's expecting the drag item to
| be still there).
|
| You might want to rethink your design.
|
| -vJ
|
| "Aron Henning" <ar**@longhorn.com> wrote in message
| news:u7**************@TK2MSFTNGP10.phx.gbl...
| >I have a ListView that contains the subfoldes of a local drive.
| > Whan i click on a subfolder the listbox should display the subfolders of
| > this folder instead.
| > the funktion is as follows:
| > private void FolderList_SelectedIndexChanged(object sender,
| > System.EventArgs
| > e)
| >
| > {
| >
| > try
| >
| > {
| >
| > ListView.SelectedListViewItemCollection SelectedDir =
| > this.FolderList.SelectedItems;
| >
| > foreach ( ListViewItem Dir in SelectedDir )
| >
| > {
| >
| > FolderList.Items.Clear();
| >
| > foreach (string d in Directory.GetDirectories(Dir.Text))
| >
| > {
| >
| > FolderList.Items.Add(d);
| >
| > }
| >
| > }
| >
| > }
| >
| > catch
| >
| > {
| >
| > MessageBox.Show("Error entering directory","Error",MessageBoxButtons.OK,
| > MessageBoxIcon.Exclamation);
| >
| > }
| >
| > }
| >
| > *
| > Now when i try to access the folder "System Volume Information" I first
| > get
| > my MessageBox and then a messagebox saying that I have an unhandled
| > exeption.
| > But the funny thing is that I only get this message in the release
| > version.
| > Can annyboddy tel me what I do rong?
| >
| > The exeption text is as follows:
| >
| > ************** Exception Text **************
| > System.ArgumentOutOfRangeException: Specified argument was out of the
| > range
| > of valid values.
| > Parameter name: '5' is not a valid value for 'displayIndex'.
| > at System.Windows.Forms.ListViewItemCollection.get_It em(Int32
| > displayIndex)
| > at System.Windows.Forms.ListView.LvnBeginDrag(MouseBu ttons buttons,
| > NMLISTVIEW nmlv)
| > at System.Windows.Forms.ListView.WmReflectNotify(Mess age& m)
| > at System.Windows.Forms.ListView.WndProc(Message& m)
| > at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
| > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
| > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
| > IntPtr wparam, IntPtr lparam)
| >
| >
|
|
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
3
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
0
by: Sam Barham | last post by:
I have a ListView control, for which I have overwritten the WndProc method to gain access to the WM_PAINT message and generate my own OnPaint and OnPaintBackground messages, in order to colour the...
4
by: ad | last post by:
The code below can only catch common excption. I want to catch duplicate primary key exeption and do something more. How can I catch duplicate primary key exeption try { Insert a record to...
4
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
1
by: SQLJunkie | last post by:
Hi, I have installed SQL 2005 RTM on a new server and I keep getting this error (described below) quite frequently. Was wondering if anyone has a clue on what's happening here. I tried googling...
4
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.