473,835 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

confused listview items during itemChecked Event

Hi,

I have a problem with Listview using checkboxes.

If i check items by code BEFORE the form is shown the Listview.Items
are confused during the ItemChecked Event !!!

After showing the form every thing works fine: checking items by code
as well as checking with mouse:
Using the CheckdItems Property is confused too.

I load Settings from XML into different Listboxes, depending on check-
States differnt data will load from database, so i will doing this
"initialisi ng" before showing the form.

....any and suggestions or ideas
Thanks!


Sample:

public partial class Form2 : Form
{
public Form2()
{
InitializeCompo nent();

this.listView.C heckBoxes = true;
this.listView.V iew = System.Windows. Forms.View.List ;

this.listView.C olumns.Add("Tes t");
this.listView.I tems.Add(new ListViewItem("o ne"));
this.listView.I tems.Add(new ListViewItem("t wo"));
this.listView.I tems.Add(new ListViewItem("t hree"));

this.listView.I temChecked += new
System.Windows. Forms.ItemCheck edEventHandler( this.listView_I temChecked);
}

private void listView_ItemCh ecked(object sender,
ItemCheckedEven tArgs e)
{
System.Console. WriteLine("Item Checked evt: {0} {1}" ,
e.Item, e.Item.Checked) ;
List("during event");
}

public void Test(string text, bool on)
{
List(text);
this.listView.I tems[1].Checked = on;
}

private void List(string text)
{
System.Console. WriteLine("{3}: {0}, {1}, {2}",
listView.Items[0].Text,
listView.Items[1].Text,
listView.Items[2].Text,
text.PadRight(1 5)); }
}
//---------------------------------------------------------------------

using the form in another form (e.g. Buttonclick)

Form2 frm = new Form2();
frm.Test("befor e Show", true);
frm.Show();
frm.Test("after Show", false);
will show:

before Show : one, two, three
ItemChecked evt: ListViewItem: {one} False
during event : one, one, one ! ! !
ItemChecked evt: ListViewItem: {two} False
during event : one, two, one ! ! !
ItemChecked evt: ListViewItem: {two} True
during event : one, two, one ! ! !
ItemChecked evt: ListViewItem: {three} False
during event : one, two, three

after Show : one, two, three
ItemChecked evt: ListViewItem: {two} False
during event : one, two, three
Dec 5 '07 #1
0 1899

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

Similar topics

0
1465
by: Marco Auday | last post by:
I need to associate items in two listviews. I have got the drag-and-drop operation to perform as I wanted. However, I would like the items in the target listview to be highlighted when the mouse hovers over them during the drag-and-drop operation, so that I know for sure which item I selected on the target listview. I have tried a number of approaches without success, including: 1) TargetListview.DragEnter event – tried to...
1
1893
by: Mike | last post by:
Hi, When trying to remove the icon from a ListViewItem (see code below), the icon does not always disappear. Instead, if I use another index (1, 2, etc.) then the correct icon appears. I was thinking that maybe the value "-1" is not correct. But what should be the value if someone does not want any icon? private void listView1_ItemCheck(object sender, ItemCheckEventArgs e) { ListViewItem itemChecked = this.listView1.Items; if...
2
2066
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP (non-.Net) if I wanted to fill a list it may look something like this: -------START CODE <%
3
2330
by: sherifffruitfly | last post by:
Hi, Here's a skeleton-handler of what I'm trying to do: private void editBbListView_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e) { string qEnabled = ""; string indexid = ITEM_IN_ROW_WHOSE_CHECK_JUST_CHANGED.Text;
1
7644
by: sklett | last post by:
I wasn't sure how to deal with this, but this is what I cam up with. If possible, I'd like a little feedback if there is a better way to deal with a situation where changes in an event handler cause the event to fire. private void listView_AvailableTests_ItemChecked(object sender, ItemCheckedEventArgs e) { listView_AvailableTests.ItemChecked -= listView_AvailableTests_ItemChecked;
1
5105
by: dvestal | last post by:
I have a ListView with checkboxes. I want to remove items when the checkboxes are unchecked, but to do so yields an ArgumentOutOfRangeException. Is there an easy way to get around this? A simple program that illustrates the exception is below: using System; using System.Windows.Forms; namespace WindowsApplication1
4
2675
by: spowel4 | last post by:
My form has a listview populated with the 50 states. When the user checks the checkbox within the listview for a particular state, I need to retrieve which state was checked (i.e. if AZ is checked I need to get the text AZ) and search through an array for matching text. When matching text is found I need to populate another listview with some information. So if the array is two-dimensional and I'm looking at elements (0,0 ... 0,7) for...
0
313
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the form every thing works fine: checking items by code as well as checking with mouse: Using the CheckdItems Property is confused too.
2
6834
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the form every thing works fine: checking items by code
0
9810
marktang
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...
1
10563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10237
tracyyun
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...
0
9348
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7770
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6970
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();...
0
5808
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4435
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.