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. Swaping

Swaping

Scheduled Pinned Locked Moved Visual Basic
database
3 Posts 3 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.
  • K Offline
    K Offline
    Khan Bangash
    wrote on last edited by
    #1

    I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.

    D O 2 Replies Last reply
    0
    • K Khan Bangash

      I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.

      D Offline
      D Offline
      Dave Sexton
      wrote on last edited by
      #2

      Which values? Is it to be sequential e.g. swap item at index 0 with item at index 1? Or non-sequential e.g. swap item at index 0 (or any other) with any other item in the index (swap item 4 with 9, 2 with 1, 6 with 13)? Either way the event that you're looking for is the SelectedIndexChanged event.

      1 Reply Last reply
      0
      • K Khan Bangash

        I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.

        O Offline
        O Offline
        OldWarhorse
        wrote on last edited by
        #3

        Safecom wrote:

        I m using combobox to get values from database.

        No, you are using a DataProvider to get values from the database. Those values are provided to you in a stream. You can put those values into various containers, eg. a DataTable, an Array of List Objects, etc. which can then be fed or bound to your control. They should be encapsulated in a list of business objects, (preferably using a list type that implements IList - ArrayList is good) which is then manipulated (sorted according to your business rules, which may change momentarily by user gestures such as clicking radio buttons, checkboxes, etc.) and then presented to the user in the ComboBox. You may need to add a suitable sort key to your business object to help with the re-sorting/swapping. You can do all that off the DropDown event if necessary, but you will take a performance hit. It would be better to evaluate your conditions beforehand if possible, using other control events, and re-sort the list (and rebind the list to the control) before the user drops it down. SelectedIndexChange is too late. The user has already seen the list.

        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