473,511 Members | 10,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing CheckedState or Checked-value without raising ItemChecked-event

Hi all,

in a CheckedListBox there are afaics two members that change the
checked-flag for an item i.e. SetItemChecked and SetItemCheckState.
In the online-help there is a remark that SetItemCheckState will raise
an ItemCheck-event. There is no such remark for SetItemChecked also
it also raises this event in a small testcase.
Is there any differnce between the two methods except that
SetItemCheckState allows setting the indifferent-state?
How can a checked-value be changed without raising the event?
I used to help myself with a workaround-helperflag like
m_bolHandleCheckedEvent on module-level in VB-6 and thought VB.NET was
smarter concerning this issue.
Is there a property of a CheckedListBox to dynamically suppress
ItemCheck-eventhandling?

Thanks for your help,
Alex
Feb 20 '06 #1
4 5890
Hi,

The event is going to be raised if you change the value of
checked-value. You need to use the same workaround in .net

Ken
--------------
"Alexander Mueller" <mi******@hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl...
Hi all,

in a CheckedListBox there are afaics two members that change the
checked-flag for an item i.e. SetItemChecked and SetItemCheckState.
In the online-help there is a remark that SetItemCheckState will raise
an ItemCheck-event. There is no such remark for SetItemChecked also
it also raises this event in a small testcase.
Is there any differnce between the two methods except that
SetItemCheckState allows setting the indifferent-state?
How can a checked-value be changed without raising the event?
I used to help myself with a workaround-helperflag like
m_bolHandleCheckedEvent on module-level in VB-6 and thought VB.NET was
smarter concerning this issue.
Is there a property of a CheckedListBox to dynamically suppress
ItemCheck-eventhandling?

Thanks for your help,
Alex

Feb 20 '06 #2
Alexander,

In my opinion a nice way to handle the kind of problems you have. For a
former VB6 user it looks a little bit strange. This is a sample I made some
days ago however about the same problem.

The event in both procedures do raise each other and become than recursive.
By than temporaly remove the handler and set it back at the end, they don't
give a reaction.

\\\
Private Sub SplitContainer1_SplitterMoved(ByVal sender _
As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) _
Handles SplitContainer1.SplitterMoved
RemoveHandler TextBox1.TextChanged, AddressOf TextBox1_TextChanged
TextBox1.Text = SplitContainer1.SplitterDistance.ToString
AddHandler TextBox1.TextChanged, AddressOf TextBox1_TextChanged
End Sub

Private Sub TextBox1_TextChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged
RemoveHandler SplitContainer1.SplitterMoved, AddressOf
SplitContainer1_SplitterMoved
If IsNumeric(TextBox1.Text) AndAlso CInt(TextBox1.Text) > 130 Then
SplitContainer1.SplitterDistance = CInt(TextBox1.Text)
End If
AddHandler SplitContainer1.SplitterMoved, AddressOf
SplitContainer1_SplitterMoved
End Sub
///

I hope this helps,

Cor
Feb 20 '06 #3
Cor Ligthert [MVP] schrieb:
In my opinion a nice way to handle the kind of problems you have. For a
former VB6 user it looks a little bit strange. This is a sample I made some
days ago however about the same problem.

The event in both procedures do raise each other and become than recursive.
By than temporaly remove the handler and set it back at the end, they don't
give a reaction.

\\\
Private Sub SplitContainer1_SplitterMoved(ByVal sender _
As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) _
Handles SplitContainer1.SplitterMoved
RemoveHandler TextBox1.TextChanged, AddressOf TextBox1_TextChanged
TextBox1.Text = SplitContainer1.SplitterDistance.ToString
AddHandler TextBox1.TextChanged, AddressOf TextBox1_TextChanged
End Sub

Private Sub TextBox1_TextChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged
RemoveHandler SplitContainer1.SplitterMoved, AddressOf
SplitContainer1_SplitterMoved
If IsNumeric(TextBox1.Text) AndAlso CInt(TextBox1.Text) > 130 Then
SplitContainer1.SplitterDistance = CInt(TextBox1.Text)
End If
AddHandler SplitContainer1.SplitterMoved, AddressOf
SplitContainer1_SplitterMoved
End Sub
///

I hope this helps,


Hi Cor and Ken,

thanks very much both of you for your help.
The idea of dynamically removing and reenabling the handler is nice,
although takes quite some effort if you have multiple locations for
setting checked state. I thought i had read that NET-checkboxes
straighten up with VB-6-flaws like that changing the checked-state by
code raises a click-event. There should be to my opinion some kind of
information available as to what triggered the event (user-interaction,
code or external-incident, etc).
Anyway, now I have two ways to fix it, thanks again.

Mfg,
Alex
Feb 21 '06 #4
Alexander,
I thought i had read that NET-checkboxes
straighten up with VB-6-flaws like that changing the checked-state by
code raises a click-event. There should be to my opinion some kind of
information available as to what triggered the event (user-interaction,
code or external-incident, etc).


It is completely the same in C# and C++ managed.

There is by the way no click-event raised, you are not even busy with that,
the event are one of the property changed events.

All things I have tried in another way for this, did lead to a kind of
spagetti code.

Just my idea

Cor
Feb 21 '06 #5

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

Similar topics

7
5286
by: Jim Vorbau | last post by:
I would like to change the colors on consecutive letters of a word. When adding a style associated with the span tag (see below), there is a gap after each letter. Does anyone know why the span tag...
1
3093
by: trt08010 | last post by:
I'm new to MySQL so hopefully this all makes sense. I'm running mysql-3.23.58-14 on Fedora Core 3 and everything installs and comes up correctly using default locations for everything. However,...
24
3461
by: Charles Crume | last post by:
Hello; My "index.htm" page has 3 frames (content, navigation bar, and logo). I set the "SRC" of the "logo" frame to a blank gif image and then want to change it's contents after the other two...
4
1805
by: Omey Samaroo | last post by:
I am using Employee_Number as a primary field in one table and in another table I have a field with the same name that it references in a one to many relationship. How do I change the primary field...
2
1479
by: marcmc | last post by:
Hey All, I want to find whether my first item within my CheckListBox is in a checked or unchecked state. I tried the following but it did not work, Can anyone help. If...
8
1407
by: marcmc | last post by:
Below we can get the checkedItems within a checkedListBox but I have attempted to find the unchecked items but I cannot seem to find a method. Is there one or can I somehow manipulate the below...
32
3636
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's...
1
3442
by: Tim Cowan | last post by:
Hi, I was wondering if there is a quicker way to do this? I have a select all check box for data in a grid and when checked I want the checkboxes in the grid to be checked. I am currently...
6
8353
by: Brandon McCombs | last post by:
Hello, I have a Form that contains some configuration information. One of the settings is for SSL. There is a checkbox that I want to check to make 2 textboxes un-editable so that a user can...
14
9395
by: sarabonn | last post by:
Hello everyone, In my windows form application iam having a login form with 2 textboxes for username and password and checkbox (to keep the user logged in). When the user...
0
7251
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,...
0
7367
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
7430
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
5673
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,...
0
4743
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...
0
3230
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...
0
1581
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 ...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
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...

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.