Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2005, 05:42 PM
Authorized User
 
Join Date: Jul 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# ListBox Working With Multiple Selections

Hi,

I'm working with a databound ListBox (C# 2003) , each item has a DataValue and a DisplayMember.

I want to select multiple items and get the SelectedValue of each one.

I was thinking of using a foreach loop or something along the lines of:

foreach(UnknownDataType x in ListBox.SelectiedItems)
{
MessageBox.Show(x.Value);
}

Where it prints the Value of the selected items in the list box.

I know the code is wrong, so could someone at least point me it the right direction.
 
Old October 9th, 2005, 02:15 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I don't know C# here is some VB Code you can easily convert.

        Dim lst As ListItem
        For Each lst In ListBox1.Items
            If lst.Selected = True Then
                Response.Write(lst.Text)
            End If
        Next

You can find a VB to C# code converer online

Jim






Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown list with multiple selections tombert ASP.NET 1.0 and 1.1 Basics 15 March 7th, 2007 07:38 PM
multiple listbox selections written to a text fiel pascoag Access 0 October 14th, 2004 10:01 PM
Select Menu Multiple Selections phungleon HTML Code Clinic 2 July 20th, 2004 12:25 PM
setting mult. selections in listbox at page_load jtyson General .NET 1 April 14th, 2004 07:39 AM
Cannot store multiple form selections to a mysql d scifo Beginning PHP 2 August 3rd, 2003 04:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.