Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. unhandled exeption in ListView

unhandled exeption in ListView

Scheduled Pinned Locked Moved C#
announcementhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aron Henning
    wrote on last edited by
    #1

    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_Item(Int32 displayIndex) at System.Windows.Forms.ListView.LvnBeginDrag(MouseButtons buttons, NMLISTVIEW nmlv) at System.Windows.Forms.ListView.WmReflectNotify(Message& m) at System.Windows.Forms.ListView.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    L 1 Reply Last reply
    0
    • A Aron Henning

      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_Item(Int32 displayIndex) at System.Windows.Forms.ListView.LvnBeginDrag(MouseButtons buttons, NMLISTVIEW nmlv) at System.Windows.Forms.ListView.WmReflectNotify(Message& m) at System.Windows.Forms.ListView.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Aron Henning wrote: FolderList.Items.Clear(); That will be the cause. top secret xacc-ide 0.0.1

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups