473,396 Members | 1,804 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,396 software developers and data experts.

how to prevent an event from firing?

nev
251 100+
i placed code in the itemchecked event of a checkedlistbox

now, i check the items programmatically.

what i want to achieve is that when i check the item in the program, the itemchecked event should not fire. but when the user clicks checkedlistbox to check an item, the event should fire.

how to do this?
Nov 14 '07 #1
6 1176
Plater
7,872 Expert 4TB
You could create a boolean value say "doCheckEvent".
Then in your item checked eventhandler, have it ONLY run the code if doCheckEvent=true.

So when you check items withen your code:
doCheckEvent=false;
//check some items
//check some items
//check some items
doCheckEvent=true;
Nov 14 '07 #2
nev
251 100+
You could create a boolean value say "doCheckEvent".
Then in your item checked eventhandler, have it ONLY run the code if doCheckEvent=true.

So when you check items withen your code:
doCheckEvent=false;
//check some items
//check some items
//check some items
doCheckEvent=true;
thank you. does this mean i need to declare a global variable for the class? or is there some other way i can pass or check this value instead of declaring it as global?

- will wait for response
Nov 15 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
thank you. does this mean i need to declare a global variable for the class? or is there some other way i can pass or check this value instead of declaring it as global?

- will wait for response
Well, its not exactly a global variable, its a variable in the class, which can be accessed by all the methods in it.
Everytime your even is fired, it will have to check if it is the right time to start the event or not.
Nov 15 '07 #4
nev
251 100+
Well, its not exactly a global variable, its a variable in the class, which can be accessed by all the methods in it.
Everytime your even is fired, it will have to check if it is the right time to start the event or not.
oh my bad. i think its called public variable. this is amazing! i'll try it in my code now. you're all great help :-)
Nov 15 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
oh my bad. i think its called public variable. this is amazing! i'll try it in my code now. you're all great help :-)
You wont have the need to have it public, unless you want other forms to control the variable.
If you are changing the value of this vcariable within the form itself, then private is the way to go, will lessen the clutter in intellisense too !
Nov 15 '07 #6
nev
251 100+
You wont have the need to have it public, unless you want other forms to control the variable.
If you are changing the value of this vcariable within the form itself, then private is the way to go, will lessen the clutter in intellisense too !
oohhhh....yesss...yessssss. thank you for enlightening me :-)
Nov 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
1
by: Stan | last post by:
If a page has a button with event handler private void btnAdd_Click(object sender, System.EventArgs e) { ....... } this event handler fires every time I refresh the page in the browser with...
9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
15
by: Billy | last post by:
Anyone know if this a bug in VB.NET 2002 and how to overcame that situation? I have a MDI form from where I call MDI child form like that: Dim frm As New frmChild() frm.MdiParent = Me...
3
by: tlyczko | last post by:
Hello, I think what I'm asking for may not be possible, but I'll try anyway. I have MainForm with 3 subforms, one SubForm requires data entry, the other two don't (optional). MainForm has...
4
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
3
by: Mike-deerenews | last post by:
I would like to check for the existence of an attribute in order to prevent an exception from firing. Could someone provide an example? tia Mike
2
by: APA | last post by:
Why does adding code to the form submit function using the RegisterOnSubmitStatement method prevent the server side event handler for the submit button from firing? This is completely useless. I...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
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,...

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.