Solved

Right Align Edit Boxes

Posted on 2003-11-04
7
510 Views
Last Modified: 2010-04-05
Can anyone please help me.  I am having extreme diffuculty with right aligning edit boxes.  

I have an app that uses numbers and it is very frustrating that I can't have my decimal places lined up to the right of an edit box in Delphi.  Very frustrating considering Delphi is such a great language.  You can do it with no problems in VB.  

Can anyone help me and tell me what I need to do?  I am not overly experienced so detailed help would be awesome!  A great answer will mean an increase in points.  Just want to get it done.

Thanks in advance.
Boss.
0
Comment
Question by:nzboss
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9684589
from barry (inthe):

unit AlignEdit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls;

type
  TEditAlign = class(TEdit)
  private
    { Private declarations }
  f_alignment: TAlignment;
  protected
    { Protected declarations }
    procedure CreateParams(var params:TCreateParams); override;
  procedure SetAlignment(value: TAlignment);
 public
    { Public declarations }
constructor Create(AOwner: TComponent); override;
  published
    { Published declarations }
 property Alignment:TAlignment read f_alignment write SetAlignment;
 
  end;

procedure Register;

implementation
constructor TEditAlign.Create(AOwner: TComponent);
begin
  inherited create(AOwner);
  end;

procedure TEditAlign.SetAlignment(value: TAlignment);
begin
  if value<>f_alignment then begin
    f_alignment:=value;
    recreatewnd;
    end;
  end;

procedure TEditAlign.CreateParams(var params:TCreateParams);
const
    Alignments : array[TAlignment] of Longint = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
 inherited CreateParams(Params);
 Params.Style := Params.Style or Alignments[f_Alignment] or ES_MULTILINE;
  end;
procedure Register;
begin
  RegisterComponents('Samples', [TEditAlign]);
end;

end.

meikl ;-)
0
 
LVL 17

Accepted Solution

by:
geobul earned 300 total points
ID: 9685249
Hi,

I recommend you to try some of the free components from http://www.torry.net/diffedits.htm
TFloatEdit for example.

Regards, Geo
0
 

Author Comment

by:nzboss
ID: 9696696
Hi kretzschmar,

How would you go about using this code in an application?

Thanks,
Boss.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 9696718
its a component just install it into delphi-ide-component-palette,
and use it like a TEdit

meikl ;-)
0
 
LVL 1

Expert Comment

by:JackNaif
ID: 9707379
The first programme I ever wrote in Delphi was a simple calculator. I run right into this same problem. I suffered on it for a couple of days and then my teacher surprised me with an (unusally) wise answer:

"It doesn't matter what it *is*, but what it *looks like*. Use a TLabel with it's color property set to white, inside a slightly bigger TPanel with it's BevelOuter set to bvLower. Put the numbers in the Caption of the label, and use the alignment property of the label to have it align numbers to the right".

There is still a little bit of a nuisance to this solution: letting the user type or edit the numbers is a bit cumbersome, but it might still be a good solution. It worked for me. =)

Jack
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9813555
Any update here, nzboss?
0
 

Author Comment

by:nzboss
ID: 9835291
Thanks got on component that works.  Just a shame that Delphi doesn't have this already built in.  CRAZY!

Boss.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
System restore point 4 77
Delphi Dbf export problem to a Visual Foxpro application 6 122
Printing problem 2 72
Multiple image collision 13 44
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 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

19 Experts available now in Live!

Get 1:1 Help Now