473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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
"initialising" before showing the form.
....any and suggestions or ideas
Thanks!
Sample:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.listView.CheckBoxes = true;
this.listView.View = System.Windows.Forms.View.List;
this.listView.Columns.Add("Test");
this.listView.Items.Add(new ListViewItem("one"));
this.listView.Items.Add(new ListViewItem("two"));
this.listView.Items.Add(new ListViewItem("three"));
this.listView.ItemChecked += new
System.Windows.Forms.ItemCheckedEventHandler(this. listView_ItemChecked);
}
private void listView_ItemChecked(object sender,
ItemCheckedEventArgs e)
{
System.Console.WriteLine("ItemChecked evt: {0} {1}" ,
e.Item, e.Item.Checked);
List("during event");
}
public void Test(string text, bool on)
{
List(text);
this.listView.Items[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(15)); }
}
//---------------------------------------------------------------------
using the form in another form (e.g. Buttonclick)
Form2 frm = new Form2();
frm.Test("before 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 811

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

Similar topics

0
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...
1
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...
2
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...
6
by: Massimo Zaccarin | last post by:
I have a ListView with MultiSelect=True, how can I know witch Item has been clicked, without looping on each Item? I need to process only the last clicked Item, but the "Click" event doesn't...
3
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...
1
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...
1
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...
4
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...
0
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.