473,739 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Windows. Forms.ListView: OnItemCheck method called when displaying the form

Is there any way to know whether the OnItemCheck is being called in response
to a user action (mouse or keyboard) as opposed to the form loading?

I have a class which derives from System.Windows. Forms.ListView. Among
other features, it enables the checkboxes and overrides the OnItemCheck()
method. I have placed this ListView on a form and use form.ShowDialog () to
display it whenever the user presses a certain button.

If the user ticks any of the items in the ListView, and then presses the
button again, the form displays okay, but it calls the OnItemCheck() method
twice for each item that was previously checked (once to uncheck, and again
to check the item).

The problem is, that I keep track of the order in which the user checked the
checkboxes, and when OnItemCheck is called it effectively changes the order
to be the same as the insertion order in the list.

Thanks,
Aaron Queenan.
Nov 15 '05 #1
2 3008
100
Hi Aaron,
ItemCheck event is raised whenever an item changes its check status. It can
be done programmaticall y or by the user. There is no way to now how the item
has been changed its state.
However the control doesn't fire the event before it is created or if it is
created with Visible property set to false. Which means that you can fill up
and set the check status of the items without any ItemCheck event fired. But
once you show the control you cannot stop the events even if you set Visible
back to *false*.
I see that you have overridden the control. In this case you can add a
property say "bool SuppressItemChe ckEvent";
If this flag is set in your OnItemCheck don't call base.OnItemChec k this
will suppress the event.
Now you can set
SuppressItemChe ckEvent = true;
change the state of items
SuppressItemChe ckEvent = false;

HTH
B\rgds
100

"Aaron Queenan" <aq************ *********@conti ngent.com.au> wrote in message
news:u2******** ******@TK2MSFTN GP11.phx.gbl...
Is there any way to know whether the OnItemCheck is being called in response to a user action (mouse or keyboard) as opposed to the form loading?

I have a class which derives from System.Windows. Forms.ListView. Among
other features, it enables the checkboxes and overrides the OnItemCheck()
method. I have placed this ListView on a form and use form.ShowDialog () to display it whenever the user presses a certain button.

If the user ticks any of the items in the ListView, and then presses the
button again, the form displays okay, but it calls the OnItemCheck() method twice for each item that was previously checked (once to uncheck, and again to check the item).

The problem is, that I keep track of the order in which the user checked the checkboxes, and when OnItemCheck is called it effectively changes the order to be the same as the insertion order in the list.

Thanks,
Aaron Queenan.

Nov 15 '05 #2
I can get around the problem of the events firing on loading, by using the
following code at the top of OnItemCheck():

if (ice.Index >= this.Items.Coun t)
return;

However, the method still gets called if I hide then show the form. The
problem is that the ListView unchecks then rechecks each checked item in the
list. That is utterly stupid! The items haven't changed, and there is no
reason for anything to uncheck then recheck them, but perhaps when the form
recreates the underlying control the internal ListView illogic isn't clever
enough to realise that the events should be discarded, and calls
OnItemCheck().

Do you know what events fire before or after showing the form? Is there any
way to watch the events being fired, without handling them all? I am
thinking of setting a flag called "IgnoreBogusLis tViewEvents" in an event
which occurs first and clearing it afterwards.

Thanks,
Aaron.

"100" <10*@100.com> wrote in message
news:u3******** ******@TK2MSFTN GP10.phx.gbl...
Hi Aaron,
ItemCheck event is raised whenever an item changes its check status. It can be done programmaticall y or by the user. There is no way to now how the item has been changed its state.
However the control doesn't fire the event before it is created or if it is created with Visible property set to false. Which means that you can fill up and set the check status of the items without any ItemCheck event fired. But once you show the control you cannot stop the events even if you set Visible back to *false*.
I see that you have overridden the control. In this case you can add a
property say "bool SuppressItemChe ckEvent";
If this flag is set in your OnItemCheck don't call base.OnItemChec k this
will suppress the event.
Now you can set
SuppressItemChe ckEvent = true;
change the state of items
SuppressItemChe ckEvent = false;

HTH
B\rgds
100

"Aaron Queenan" <aq************ *********@conti ngent.com.au> wrote in message news:u2******** ******@TK2MSFTN GP11.phx.gbl...
Is there any way to know whether the OnItemCheck is being called in

response
to a user action (mouse or keyboard) as opposed to the form loading?

I have a class which derives from System.Windows. Forms.ListView. Among
other features, it enables the checkboxes and overrides the OnItemCheck() method. I have placed this ListView on a form and use form.ShowDialog ()

to
display it whenever the user presses a certain button.

If the user ticks any of the items in the ListView, and then presses the
button again, the form displays okay, but it calls the OnItemCheck()

method
twice for each item that was previously checked (once to uncheck, and

again
to check the item).

The problem is, that I keep track of the order in which the user checked

the
checkboxes, and when OnItemCheck is called it effectively changes the

order
to be the same as the insertion order in the list.

Thanks,
Aaron Queenan.


Nov 15 '05 #3

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

Similar topics

9
4964
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
2
16214
by: Phil Stanton | last post by:
When designing a new form or report, the Default ForeColor is often something like -2147483640 which is the colour of Windows text (possibly black) and the default backColor is -2147483643 (possibly white) Can anyone tell me how to convert these colours to either RGB colours or the Long number used by Access. Black is 0 and White is 16777215 ...
3
2225
by: Travis | last post by:
I am trying to display a query like this in my windows form: SELECT workordernumber, date, firstname, lastname FROM customer_db; I am using a rich text box to display the data but it only displays ONE record in the rich text box. How do you display all the found records. I am using the System.Data.Odbc; it is quite easy to use, but I cannot figure out how to display large
6
2877
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a TimerState object similar to the example in the System.Threading.Timer documentation. The method which handles the timer events, among other things, periodically calls a method in this TimerState object which raises an event to the startup form,...
2
7838
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item in treeview i display the content item in axWebBrowser, i close the sub form normally when i close the main the following error is generated An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll ...
7
1757
by: Steve954 | last post by:
I recently installed and started using VS2005 on a Windows XP Pro machine. When creating a new windows forms project I find that I am unable to hide any forms using the me.hide() or me.visible = False methods. As far as I can tell these methods are available and should work in VB2005. Any help and advise would be great as this is causing be a number of problems of two new projects I am working on. Many Thanks
3
4028
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user selects? thanks...
2
1504
by: feltra | last post by:
Hi, The following is from my friend, who has some technical problem at present in accessing the web... I am writing for him... Kindly request your inputs ASAP, as he has some kind of deadline tomorrow. .......................................................................................... I am having an issue with MDI form. I have an MDI form and some Child forms. In order to enable for a choice, I am displaying a message box in...
2
4501
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message boxes (please see associated source code below): 1) Win32 API with context ("btnWin32WithContext_Click") 2) .NET Framework with context ("btnFrameworkWithContext_Click") 3) Win32 API withOUT context ("btnWin32WithOUTContext_Click")
0
8969
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
9266
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
9209
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
8215
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
6754
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
6054
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
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3280
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
3
2193
bsmnconsultancy
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.