|
전병수 님이 쓰신 글 :
: 에디트박스에서 가운데 정렬을 하고 싶은데....
: 알수가 없네요.. 비쥬얼 씨 에서는 간단하게 하던데.. 쩝.
: 어떻게 방법이 없나요?....
:
: 메모장의 경우 SetTextAlign이란 함수가 TCustomMemo로 부터 상속되어 있던데..
: 에디트이 경우는 TCustomEdit인가요.. 뭐.. 여기서 갈라져서.. 물론 위의 메모는 에디트로 부터 상속이고. 쩝..
: 여튼.
:
:
: 부탁드립니다... 에디트박스에서 문자를 오른쪽이나.. 가운데 정렬을 하고 싶습니다.
밑의 글은 델파이 코리아에서 받아온
스트링 그리드에서 문자열 정렬하기 소스 입니다. 참고 될지 모르겠네요
그럼 이만
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with TStringGrid(Sender).Canvas do
begin
FillRect(Rect);
TextOut(Rect.Left + 2, Rect.Top+2, TStringGrid(Sender).Cells[ACol, ARow]);
end;
end;
// ***********************************************************************
// 가운데 정렬 ***********************************************************
// ***********************************************************************
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
LeftPos: Integer;
CellStr: string;
begin
with TStringGrid(Sender).Canvas do
begin
CellStr := TStringGrid(Sender).Cells[ACol, ARow];
LeftPos := ((Rect.Right - Rect.Left -
TStringGrid(Sender).Canvas.TextWidth(CellStr)) div 2) + Rect.Left;
FillRect(Rect);
TextOut(LeftPos, Rect.Top+2, CellStr);
end;
end;
// ***********************************************************************
// 오른쪽 정렬 ***********************************************************
// ***********************************************************************
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
LeftPos: Integer;
CellStr: string;
begin
with TStringGrid(Sender).Canvas do
begin
CellStr := TStringGrid(Sender).Cells[ACol, ARow];
LeftPos := Rect.Right - TStringGrid(Sender).Canvas.TextWidth(CellStr);
FillRect(Rect);
TextOut(LeftPos-2, Rect.Top+2, CellStr);
end;
end;
|