?
Solved

Basic beginner's question regarding TUpDown (Delphi)

Posted on 2009-05-15
2
Medium Priority
?
889 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 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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