472,353 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

ListViewItem.Selected and SelectedIndexChanged


I would like to manually set one of my list view items as selected. When this item is set, I would like for a method to execute. I have a delegate on the list view for SelectedIndexChanged. For some reason, when I set the listviewitem.Selected = true, the event is not fired. Here is my code:

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
list.Items[i].Selected = true;

private ListView list = new ListView();

static void Main()
DomainObjectModelListView listView = new DomainObjectModelListView();
Jul 21 '05 #1
0 1763

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Fritz | last post by:
I know it, I know it. It's come up a lot. I've done the Googling, but the standard answer doesn't do what I expect it to. For the record, the...
by: Kluch | last post by:
I am trying to select and focus single ListViewItem and can't seem to do so, here is my code: IEnumerator * itemList =...
by: Aaron Prohaska | last post by:
I'm having the problem with this drop down list on postback. For some reason both the ListItems get selected when I change the selected item. Using...
by: moondaddy | last post by:
I have a dropdown combo box on a form and I have its AutoPostBack property set to true. When I select something from the list it does a postback...
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the...
by: Graham | last post by:
Hi everyone I have a form which contains a ListView control. The code handles the SelectedIndexChanged event, and changes some icons on some...
by: LagartijaNick | last post by:
Question: I have a ListView in which I'm selecting a ListViewItem based on the value of a textbox. On my XP machine (with default color scheme)...
by: LV | last post by:
Hello, I would like to manually set one of my list view items as selected. When this item is set, I would like for a method to execute. I have a...
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.