?
Solved

Basic beginner's question regarding TUpDown (Delphi)

Posted on 2009-05-15
2
Medium Priority
?
893 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
2 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 500 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 38

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

862 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