By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,100 Members | 1,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,100 IT Pros & Developers. It's quick & easy.

ListView.SelectedIndexChanged not firing

P: n/a

When I manually set a list view item to be a selected item, the SelectedIndexChanged event is not firing. Am I missing something here?

using System;
using System.Windows.Forms;

namespace DOMBuilder.GUI
public delegate void SelectedDomainObjectChangedHandler();

public class DomainObjectModelListView
public DomainObjectModelListView()
list.SelectedIndexChanged +=
new EventHandler(SelectedIndexChanged);

list.Items.Add(new ListViewItem("Item1"));
list.Items.Add(new ListViewItem("Item2"));
list.Items.Add(new ListViewItem("Item3"));

protected virtual void SelectedIndexChanged(object sender, EventArgs e)
Console.WriteLine("In SelectedIndexChanged");

public void SelectItem(int i)
// SelectedIndexChanged should fire after this call but doesn't
list.Items[i].Selected = true;

private ListView list = new ListView();

static void Main()
DomainObjectModelListView listView = new DomainObjectModelListView();
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.