473,766 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to stop a handle being called

Hi,

I'm a bit of a newbie to VB.NET so please forgive me if I get the
terminology incorrect... I'm still learning :)

I have a form with five numUpDown controls representing different ratios for
5 diferent things. Next to them are 5 checkboxes that can be used to lock
it's relevant ratio. I'm trying to get them to automatically distribute a
total of 100 amongst themselves. I've managed to get this working - almost...

The process I have is that when a user changes a value in one of the
numUpDown controls, the .OnChange handle for that control calls a method that
calculates the new values for the remaining 4 NumUpDown controls and updates
them.

The problem I have, is that because the same method is used by all the
NumUpDown controls using the .OnChange handle then when one of the Controls
changes the ratios and updates the values in the remaining 4 controls then
their .OnChange handles are called and they automatically reset the value of
the original changed control. I hope this makes sense.

So is there any way to change a value in a control and then stop it's
OnChange Handle from calling a method?

Cheers

Niels
Nov 21 '05 #1
4 1524
Hi Niels,

I would do this in the following way:

Private Calculating As Boolean

Private Sub NumericUpDown1_ ValueChanged(By Val sender As Object, ByVal e As
System.EventArg s) Handles NumericUpDown1. ValueChanged,
NumericUpDown2. ValueChanged
If Not Calculating Then
Calculating = True
CalculateOthers (CType(sender, NumericUpDown))
Calculating = False
End If
End Sub

Private Sub CalculateOthers (ByVal Sender As NumericUpDown)
'calculate the values of the other controls
If ReferenceEquals (Sender, Me.NumericUpDow n1) Then
Me.NumericUpDow n2.Value = 100 - Me.NumericUpDow n1.Value 'could be
any calculation of course
Else
Me.NumericUpDow n1.Value = 100 - Me.NumericUpDow n2.Value 'could be
any calculation of course
End If
End Sub

Hope this helps
Stefan
"Niels Jensen" <Niels Je****@discussi ons.microsoft.c om> wrote in message
news:57******** *************** ***********@mic rosoft.com...
Hi,

I'm a bit of a newbie to VB.NET so please forgive me if I get the
terminology incorrect... I'm still learning :)

I have a form with five numUpDown controls representing different ratios
for
5 diferent things. Next to them are 5 checkboxes that can be used to lock
it's relevant ratio. I'm trying to get them to automatically distribute a
total of 100 amongst themselves. I've managed to get this working -
almost...

The process I have is that when a user changes a value in one of the
numUpDown controls, the .OnChange handle for that control calls a method
that
calculates the new values for the remaining 4 NumUpDown controls and
updates
them.

The problem I have, is that because the same method is used by all the
NumUpDown controls using the .OnChange handle then when one of the
Controls
changes the ratios and updates the values in the remaining 4 controls then
their .OnChange handles are called and they automatically reset the value
of
the original changed control. I hope this makes sense.

So is there any way to change a value in a control and then stop it's
OnChange Handle from calling a method?

Cheers

Niels

Nov 21 '05 #2
Niels,

The most simple one for your problem is in my opinion to use a switch.

A more direct answer on your question looks for me the Remove and at the end
Addhandler

http://msdn.microsoft.com/library/de...rstatement.asp

I hope this helps

Cor
Nov 21 '05 #3
"Niels Jensen" <Niels Je****@discussi ons.microsoft.c om> schrieb:
I have a form with five numUpDown controls representing different ratios
for
5 diferent things. Next to them are 5 checkboxes that can be used to lock
it's relevant ratio. I'm trying to get them to automatically distribute a
total of 100 amongst themselves. I've managed to get this working -
almost...

The process I have is that when a user changes a value in one of the
numUpDown controls, the .OnChange handle for that control calls a method
that
calculates the new values for the remaining 4 NumUpDown controls and
updates
them.

The problem I have, is that because the same method is used by all the
NumUpDown controls using the .OnChange handle then when one of the
Controls
changes the ratios and updates the values in the remaining 4 controls then
their .OnChange handles are called and they automatically reset the value
of
the original changed control. I hope this makes sense.


\\\
Private m_CalledByCode As Boolean
..
..
..
Public Sub NumericUpDown1_ ...(...) Handles...
If Not m_CalledByCode Then
...
End If
End Sub
..
..
..
m_CalledByCode = True
SetOtherNumeric UpDownControls( )
m_CalledByCode = False
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
Hi,

Thanks for the help guys - I'll have a look at what I can do with your advice

Cheers
Niels

"Herfried K. Wagner [MVP]" wrote:
"Niels Jensen" <Niels Je****@discussi ons.microsoft.c om> schrieb:
I have a form with five numUpDown controls representing different ratios
for
5 diferent things. Next to them are 5 checkboxes that can be used to lock
it's relevant ratio. I'm trying to get them to automatically distribute a
total of 100 amongst themselves. I've managed to get this working -
almost...

The process I have is that when a user changes a value in one of the
numUpDown controls, the .OnChange handle for that control calls a method
that
calculates the new values for the remaining 4 NumUpDown controls and
updates
them.

The problem I have, is that because the same method is used by all the
NumUpDown controls using the .OnChange handle then when one of the
Controls
changes the ratios and updates the values in the remaining 4 controls then
their .OnChange handles are called and they automatically reset the value
of
the original changed control. I hope this makes sense.


\\\
Private m_CalledByCode As Boolean
..
..
..
Public Sub NumericUpDown1_ ...(...) Handles...
If Not m_CalledByCode Then
...
End If
End Sub
..
..
..
m_CalledByCode = True
SetOtherNumeric UpDownControls( )
m_CalledByCode = False
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

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

Similar topics

2
2371
by: Mike Bennett | last post by:
Does the .NET framework (using VB.NET) support the ability to programmatically STOP a device prior to its removal from the system? I have need to move data from a computer on one network to a computer on a different network. For various reasons, I am not allowed to join these networks. Additionally, neither computer is allowed to disconnect from its network to connect to the other network I have decided to use a USB jump drive to move the...
2
7213
by: Simon Niederberger | last post by:
Hi I've written a Windows Service which has - several (0-100) listeners threads which spawn worker threads based on events, timers etc - several (0-300) worker threads which handle data (message based) and terminate after processing I'm wondering what exactly happens when I stop the service. I don't see an ThreadAbortedException, but I'm worried my worker threads might be
7
3256
by: Tony Johansson | last post by:
Hello!! Assume I have a handle body pattern with classes called Handle and Body. In the Body class I store one int value for example 7 or some other integer value. In the Handle class I have a pointer to the Body class. If a want to create a STL container of List with the following declaration List <Handle <Body> > list
11
14975
by: Frank Rizzo | last post by:
Hello, My c# based windows service takes a while to dispose. I have to release bunch of resources all over the place and unfortunately it can take 20-40 seconds before I can cleanly exit. Every now and then, when I stop the service from the Services applet, it will timeout and bring up an error message saying that the service isn't responding.
1
1590
by: Prasad | last post by:
Hi, I am writing a service which takes a long time to stop after the OnStop call is given by the Services Snap-in. The problem is I cannot cut down on the time that it takes to Stop. The Service snap-in gives me the error saying that the service did not respond to the Stop call in a timely fashion. So is there any method by which I can get around this problem. Thanks Prasad
7
4584
by: Denise | last post by:
I just realized the DataTable_RowChanging events were firing when I called Fill method of the DataAdapter! It fires TWICE for each row loaded. I thought these were only supposed to be called when data was actually being edited. I am using bound textbox controls on the form. Could that have anything to do with it? Does anyone know how to stop the RowChanging events from firing? Thanks!
51
54870
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() # This thread is expected to finish within a second
7
7232
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch this error. I want to restart my windows service every time the COM object throws an error. I use System.ServiceProcess.ServiceController to stop and start my service. But there is one thing I do not understand:
2
35620
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the implementation so the two can vary independently. Handle classes usually contain a pointer to the object implementation. The Handle object is used rather than the implemented object. This leaves the implemented object free to change without affecting...
0
9568
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...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10008
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8833
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...
0
6651
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
5279
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...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.