Solved

Basic beginner's question regarding TUpDown (Delphi)

Posted on 2009-05-15
2
875 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 125 total points
Comment Utility
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 36

Expert Comment

by:Geert Gruwez
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now