Click here to Skip to main content
15,891,905 members

Comments by Member 8172875 (Top 27 by date)

Member 8172875 19-Nov-12 2:17am View    
int itemCount = listBox1.SelectedItems.Count;
string str="";

for (int i = 0; i < itemCount; i++)
{

str += listBox1.SelectedItems[i].ToString() + "','";

}
Member 8172875 19-Nov-12 2:15am View    
thanks Dominic. i have done with some modification on your code and its working properly .. thanks for the help
Member 8172875 18-Nov-12 23:38pm View    
Error 1: The best overloaded method match for 'string.Join(string, string[])' has some invalid arguments

Error 2: Argument '2': cannot convert from 'System.Collections.Generic.List<string>' to 'string[]'

I got two errors while trying your code.. you are correct. i am working on windows application.
Member 8172875 17-Nov-12 2:14am View    
actually i want a string of multiple selected values from listbox. and use this string into where clause for IN() statement. it will fetch all records which are selected by user in listbox and display records on gridview.
Member 8172875 17-Nov-12 2:09am View    
i am using sample code 2 and get this Error 1 'object' does not contain a definition for 'Selected' and no extension method 'Selected' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) C:\Users\admin\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\PrintSalarySlip.cs 184 47 WindowsFormsApplication1