Solved

Basic beginner's question regarding TUpDown (Delphi)

Posted on 2009-05-15
2
886 Views
Last Modified: 2013-11-23
Hey all,

I just have a basic beginner's question regarding the TUpDown feature.

What I want to achieve is when the user presses UP on UpDown1(OnClick ?)  then something should happen, say Showmessage('Up'); and if they press DOWN, then f.e. ShowMessage('Down').

Tried searching for this, but couldn't find it.
0
Comment
Question by:MerlaP83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 125 total points
ID: 24393495
Use the OnClick event. You'll notice that the button that was pressed (up or down) is passed to the procedure:
  procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);

You would then say
begin
  if Button = btNext then showmessage('next');
  if Button = btPrev then showmessage('previous');
end;

But that's lame code, this is slightly more elegant::
  if BUtton = btNext then showmessage('next') else showmessage('previous');
end;
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24395262
you can even go compact ...

use StrUtils;

procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
  ShowMessage(IfThen(Button = btNext, 'next', 'previous'));
end;
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question