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. Visual Basic
  4. List box Problem

List box Problem

Scheduled Pinned Locked Moved Visual Basic
helpquestion
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.
  • B Offline
    B Offline
    bensoncd
    wrote on last edited by
    #1

    I have a form containing two list boxes and two buttons. The form loads with a list of 50 items on Listbox1 and Listbox2 is empty. When you select an item from ListBox1 and then press Button1, the selected item is moved to ListBox2. When you select an item from List Box2 and press button2, the item is returned to ListBox1. However I want to code my program such that when the user presses button2 without selecting an item from Listbox2 , there is no program error created, but the program simply tells the user to select an item. Currently my program halts and gives me the following message box: An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll Additional information: Specified argument was out of the range of valid values. Help Me Folks Problem 2 How can I make an item that has been return back to Listbox1 appear in a different color?

    E 1 Reply Last reply
    0
    • B bensoncd

      I have a form containing two list boxes and two buttons. The form loads with a list of 50 items on Listbox1 and Listbox2 is empty. When you select an item from ListBox1 and then press Button1, the selected item is moved to ListBox2. When you select an item from List Box2 and press button2, the item is returned to ListBox1. However I want to code my program such that when the user presses button2 without selecting an item from Listbox2 , there is no program error created, but the program simply tells the user to select an item. Currently my program halts and gives me the following message box: An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll Additional information: Specified argument was out of the range of valid values. Help Me Folks Problem 2 How can I make an item that has been return back to Listbox1 appear in a different color?

      E Offline
      E Offline
      Edbert P
      wrote on last edited by
      #2

      1. In your Button2 click handler, write something like this: If ListBox2.SelectedItems.Count > 0 Then 'Code to move your items from ListBox2 to ListBox1 Else MsgBox("Please select an item from ListBox2") End If 2. I don't think the standard listbox supports having different fonts for its items. You may have to create your own user control for that. See example Color List Box[^].

      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