TeChNiCh
asked on
Memo1 Specify
i asked this question b4 but i want it more specified this time :)
i want to specify a memo1 format so on buttonclick then Add(Edit1.text, Edit2.text,edit3.text,edit 4.text)
and when its done i want memo1 to look like Columns this but with out the |'s:
Description | Amount |Price |Total Price |
-------------------------- ---------- ---------- --------
Edit1.text | Edit2.t | Edit3 | Edit4.text |
The lines is just the "column" where each edit should be..
its seems hard... hope someone can help
i want to specify a memo1 format so on buttonclick then Add(Edit1.text, Edit2.text,edit3.text,edit
and when its done i want memo1 to look like Columns this but with out the |'s:
Description | Amount |Price |Total Price |
--------------------------
Edit1.text | Edit2.t | Edit3 | Edit4.text |
The lines is just the "column" where each edit should be..
its seems hard... hope someone can help
The first thing, you should do, is to set Fixed-Pitch font, like System or FixedSys to the memo, then just count length of each cell in characters.
Think, that is what you're looking for:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Add: TButton;
procedure AddClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const MaxCols=15;
MaxDescription=25;
var
Form1: TForm1;
TempelateText: string;
TempelateNum: string;
implementation
{$R *.DFM}
procedure TForm1.AddClick(Sender: TObject);
begin
Memo1.Lines.Add(Format(Tem pelateNum, [Edit1.Tex t, StrToInt(Edit2.Text), StrToCurr(Edit3.Text), StrToCurr(Edit4.Text)]));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Font.Name:='Courier' ;
Memo1.Font.Pitch:=fpFixed;
TempelateText:= '%-' + IntToStr(MaxDescription)+' s | %'+IntToStr(MaxCols)+'s | %'+IntToStr(MaxCols)+'s | %'+IntToStr(MaxCols)+'s';
TempelateNum:= '%-' + IntToStr(MaxDescription)+' s | %'+IntToStr(MaxCols)+'d | %'+IntToStr(MaxCols)+'m | %'+IntToStr(MaxCols)+'m';
Memo1.Lines.Add(Format(Tem pelateText ,['Descrip tion', 'Amount', 'Price', 'Total Price']));
Memo1.Lines.Add(StringOfCh ar('-',Len gth(Memo1. Lines[0])) );
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Add: TButton;
procedure AddClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const MaxCols=15;
MaxDescription=25;
var
Form1: TForm1;
TempelateText: string;
TempelateNum: string;
implementation
{$R *.DFM}
procedure TForm1.AddClick(Sender: TObject);
begin
Memo1.Lines.Add(Format(Tem
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Font.Name:='Courier'
Memo1.Font.Pitch:=fpFixed;
TempelateText:= '%-' + IntToStr(MaxDescription)+'
TempelateNum:= '%-' + IntToStr(MaxDescription)+'
Memo1.Lines.Add(Format(Tem
Memo1.Lines.Add(StringOfCh
end;
end.
TeChNiCh,
You have 10 of the 16 questions you've asked at Experts Exchange still open, dating back to March of 2001. That, to put it mildly, is a horrible grading record.
Part of being a member here is closing your questions. Please take care of these in short order.
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20494438/Trying-to-delete-a-record.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
Netminder
EE Admin
You have 10 of the 16 questions you've asked at Experts Exchange still open, dating back to March of 2001. That, to put it mildly, is a horrible grading record.
Part of being a member here is closing your questions. Please take care of these in short order.
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20494438/Trying-to-delete-a-record.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
Netminder
EE Admin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
GL
Mike