Curious about multiselect behavior-VBForums
Results 1 to 7 of 7

Thread: Curious about multiselect behavior

  1. #1

    Thread Starter
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    23,852

    Curious about multiselect behavior

    The multiselect Listbox seems to work in an odd way in ASP.NET. In a Windows Forms app, a Listbox in multiselect allows for the ready selection of multiple items by clicking on them. In the ASP.NET version, it appears that the listbox only allows multi-selection by holding down the Ctrl or Shift keys. Am I missing something? And if not, can anybody tell me why there is this difference?
    My usual boring signature: Nothing

  2. #2
    Member
    Join Date
    Jan 2012
    Posts
    46

    Re: Curious about multiselect behavior

    The default for ListSelectionMode is set to single, you have to set it to multiple in order to get or set multiple selections.

    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx

    for windows forms, default is set to one, maybe in the apps you use the default has been changed, not really sure as I am not all that familar with Window Apps
    Last edited by jdogg; Feb 1st, 2012 at 01:09 PM. Reason: Added info

  3. #3
    Member
    Join Date
    Jan 2012
    Posts
    46

    Re: Curious about multiselect behavior

    Oh sorry I misread the fact you said a listbox in multiselect, so the listbox has been set to allow multiple selections already, well at least that is how i understand it

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,962

    Re: Curious about multiselect behavior

    Hey Shaggy,

    This is one of those situations where it "works as intended". The default action is for the ListBox to only do multi select when you first hold down CTRL.

    There are ways around this:

    http://josephschrag.blogspot.com/201...istbox-do.html

    But you might want to look into other options, i.e. 3rd party controls, before going down this type of route.

    Gary

  5. #5

    Thread Starter
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    23,852

    Re: Curious about multiselect behavior

    Yeah, I actually found a very nice looking 3rd party control, and might very well go that route (actually, the whole thing isn't up to me). I also see that this is "as intended", yet the difference between the way the multi-select listbox works in a Forms app and an ASP app is pretty peculiar. I actually had to go back to try out a multiselect winforms listbox just to be sure I wasn't hallucinating, but I wasn't.

    What I'm curious about is whether or not there is some fundamental reason why MS decided to do this odd thing? Frankly, the winforms listbox works in a much more friendly way, so why change it for ASP unless it was necessary? Was it necessary, and if so, why?
    My usual boring signature: Nothing

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,962

    Re: Curious about multiselect behavior

    Hello,

    On that note, it is difficult to say.

    It could be something to do with the way AutoPostBack's are implemented, or, more likely a limitation of the HTML rendering of a ListBox.

    Remember, an ASP.Net Listbox renders as an HTML select element, so it isn't a simple Win Forms Control to Web Forms Control comparison. It is a Win Forms Control to HTML control comparison.

    Gary

  7. #7

    Thread Starter
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    23,852

    Re: Curious about multiselect behavior

    That sounds right. I'll leave it open, for now, but I suspect that the answer lies in there.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.