Solved

Basic beginner's question regarding TUpDown (Delphi)

Posted on 2009-05-15
2
885 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
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.

730 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