Please chk if you have give the following NAMESPACE
1. For Windows Application
using System.Windows.Controls.ListBox
2. For ASP.Net Application
using System.Web.UI.WebControls;
3. For WPF Application
using System.Windows.Documents;
And Instead of "FOR Loop" use the following
private void button1_Click(object sender, System.EventArgs e)
{
String strItem;
foreach(Object selecteditem in listBox1.SelectedItems)
{
strItem = selecteditem as String;
MessageBox.Show(strItem);
}
}
Hope this will give you an idea