|
-
Apr 29th, 2003, 02:54 PM
#1
Thread Starter
New Member
NumericUpDown - up or down???
Is there any way I can recognize whether I`ve clicked the upButton or the DownButton in NumericUpDown-box??
-
Apr 29th, 2003, 04:04 PM
#2
Frenzied Member
one way i can think of is defining a static value in value_changed event and compare it with current value.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 29th, 2003, 05:34 PM
#3
Thread Starter
New Member
Originally posted by Lunatic3
one way i can think of is defining a static value in value_changed event and compare it with current value.
I`m afraid I need a dynamic value to compare the value with
I got 4 different operations to choose between and I need spesificly to know whether the value changed up or down.
But I`m working on a way to locate the boxes in the form, which seems to work okay. But I also need to know where the form is on the screen. Got any tips, how to find out the forms top-position on the screen??
-
Apr 29th, 2003, 06:54 PM
#4
Thread Starter
New Member
I solved my problem like this:
1)Add eventhandler to NumericUpDown
AddHandler numBox.ValueChanged, AddressOf NumericUpDown_ValueChanged
2)Find the exact position to the NumericUpDown-box
If ((Cursor.Position.Y - 30) < ((sender.top + Form.ActiveForm.DesktopLocation.Y) + (sender.height / 2))) Then
counter -= 1
ElseIf ((Cursor.Position.Y - 30) > ((sender.top + Form.ActiveForm.DesktopLocation.Y) + (sender.height / 2))) Then
counter += 1
End If
-
Apr 29th, 2003, 11:39 PM
#5
Frenzied Member
I am sorry about static value. I meant an Static Variable. That is a variable tat its value does not reset each time the event is fired.
put this code in change event of your numeric updown
VB Code:
Static Dim original_Value as Single=0 'This is the original value you give to your numericupdown
If myNumUpDwn.Value > original_value Then
Messagebox.Show("Going UP") ' or any toher code
Elseif myNumUpDwn.Value< original_value Then
Messagebox.Show("Going Down") 'or any other code
Else
Messagebox.Show("No Change") ' Any code here
End if
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 30th, 2003, 02:47 PM
#6
Frenzied Member
What about something like this:
VB Code:
Dim fPreviousValue As Single = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With NumericUpDown1
.DecimalPlaces = 1
.Increment = 0.5
.Maximum = 3
.Minimum = -1
fPreviousValue = .Value
End With
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
'Determine which way the value of the control has changed
If NumericUpDown1.Value > fPreviousValue Then
lblStatus.Text = "UP"
ElseIf NumericUpDown1.Value < fPreviousValue Then
lblStatus.Text = "down"
Else
lblStatus.Text = ""
End If
fPreviousValue = NumericUpDown1.Value
End Sub
~Peter

-
May 1st, 2003, 06:44 AM
#7
Thread Starter
New Member
Hey, tanks MrGTI! That was exactly what I awas looking for.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|