473,702 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListViewItem.Se lected and SelectedIndexCh anged


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 SelectedIndexCh anged. For some reason, when I set the listviewitem.Se lected = true, the event is not fired. Here is my code:

using System;
using System.Windows. Forms;

namespace DOMBuilder.GUI
public delegate void SelectedDomainO bjectChangedHan dler();

public class DomainObjectMod elListView
public DomainObjectMod elListView()
list.SelectedIn dexChanged +=
new EventHandler(Se lectedIndexChan ged);

list.Items.Add( new ListViewItem("I tem1"));
list.Items.Add( new ListViewItem("I tem2"));
list.Items.Add( new ListViewItem("I tem3"));

protected virtual void SelectedIndexCh anged(object sender, EventArgs e)
Console.WriteLi ne("In SelectedIndexCh anged");

public void SelectItem(int i)
// SelectedIndexCh anged should fire after this call
list.Items[i].Selected = true;

private ListView list = new ListView();

static void Main()
DomainObjectMod elListView listView = new DomainObjectMod elListView();
listView.Select Item(0);
Jul 21 '05 #1
0 1874

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 standard answer is: "Set the Selected property of a ListViewItem to true." I also know from MSDN that the selection won't really take effect until the ListView has focus. My specific problem is that setting item.Select = true doesn't actually select my item (or at least, doesn't highlight it). I'm...
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 = mLsvMyList->Items->GetEnumerator(); while (itemList->MoveNext()) { ListViewItem * currentItem = static_cast<ListViewItem*>(itemList->Current); String * tagData = static_cast<String*>(currentItem->Tag); if(verString->Equals(tagData))
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 the code below I'm building the drop down list in the overriden CreateChildControls method and setting the selected item. Then when I change the item in the drop down list the list is rebuilt from viewstate, but the initial item is still selected causing the error below. I also have a number...
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 and then the Page_Load event fires followed by it's SelectedIndexChanged event. However, when I go back to this control again and select the first item in the list, it does a postback and the Page_Load event fires, but the SelectedIndexChanged doesn't fire. Why does the SelectedIndexChanged get...
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 checkBoxes are selected. But what i want is to be able to get a Boolean value TRUE or FALSE when a checkBox is selected. When the checkBoxList was out of the DataList i used "OnSelectedIndexChanged" and it was returning what i wanted but if its in a
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 items in the ListView. I've found that when I deactivate and reactivate the form (an MDI child, in case that matters), the SelectedIndexChanged event is fired. On its own, that's not a problem... but the following code causes trouble:
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) the ..Selected row is a noticable grey (back color of ListView is white). However, on a custom Win2K desktop, the selected item is a faint grey and the users can barely see the highlighted row. The custom desktop settings have been locked down (ie. cannot be changed via Control Panel etc.)
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 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();
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.