G
Guest
Hello,
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.Selected = true;
}
private ListView list = new ListView();
static void Main()
{
DomainObjectModelListView listView = new DomainObjectModelListView();
listView.SelectItem(0);
}
}
}
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.Selected = true;
}
private ListView list = new ListView();
static void Main()
{
DomainObjectModelListView listView = new DomainObjectModelListView();
listView.SelectItem(0);
}
}
}