我想实现支持显示从上往下书写的文字(如:蒙古文)的控件。想了一些办法,不过觉得有点复杂。能否通过改改控件属性来实现这个功能啊?哪位高人能指点一下?控件必须是内容可编辑控件,如:edit,memo,richedit等。
我想到的办法就是限制一个memo的行数,让它可以向有方向伸展,然后通过一些计算,把字符串拆分成字符,一个一个的显示。如行数是10,第一行第一个字符显示字符串第一个字符,第一行第二个字符显示字符串第十一个字符.....不过这样做真的有点复杂。哪位高人有更好的办法啊???
我想到的办法就是限制一个memo的行数,让它可以向有方向伸展,然后通过一些计算,把字符串拆分成字符,一个一个的显示。如行数是10,第一行第一个字符显示字符串第一个字符,第一行第二个字符显示字符串第十一个字符.....不过这样做真的有点复杂。哪位高人有更好的办法啊???
解决方案 »
- 批量插入数据时,如何添加凭证号?
- 我添加一个Until单元,在里面定义一个类,却编译错呢?
- Socket写失败的解决方案
- TRichEdit.Lines的Insert方法怎么使用?(在线)
- 新手提问,请多指点!
- delphi中调用函数的问题,编译可以通过,运行时有错误呀~!!这个问题偶已经想了很久,还是不知道原因,跪求高手帮忙~!!!!!
- 可用分4469,晕,到哪天才能花完啊,跟就送- 花开两多
- 江湖告急!!!!!!!!!!
- 请问delphi的richedit可用的最新版本在什么地方下载?
- 如何在三层结构上把远处托管服务器上的数据库内容导入本地服务器的数据库上。
- 如何清除工程文件里的无效引用呀?
- BCB调用DLL出错,求高手解答
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, cxRichEdit, cxGridCustomTableView,
cxGridTableView, cxControls, cxGridCustomView, cxClasses, cxGridLevel,
cxGrid, cxLabel, cxContainer, cxTextEdit, cxMemo, StdCtrls;type
TForm1 = class(TForm)
procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationconst iRowcount=20; //限定每列行数为20行
iColcount=100; //设定100列var s:string;
StringGrid1:TStringGrid;
Button1:TButton;{$R *.dfm}procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
var i,y:integer;
procedure Focus; begin
StringGrid1.setFocus;
if i+ARow<iRowcount-1 then begin
StringGrid1.row:=ARow+i+1;
StringGrid1.col:=y;
inc(i);
end
else begin
StringGrid1.row:=0;
i:=0;
y:=y+1;
if y=StringGrid1.ColCount then begin
StringGrid1.ColCount:=StringGrid1.ColCount+1;
StringGrid1.ColWidths[y]:=12;
StringGrid1.RowHeights[y]:=16;
end;
StringGrid1.col:=y;
end;
end;
begin
s:=Value;
y:=ACol;
if length(s)=0 then exit;
StringGrid1.Cells[ACol,ARow]:=s[1];//这里仅考虑单字节字符输入
delete(s,1,1);
i:=0;
while length(s)>0 do begin//输入内容是粘贴而来,并且,字符个数在2个以上则进入循环
Focus;
StringGrid1.Cells[y,ARow+i]:=s[1];
delete(s,1,1);
end;
Focus;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
StringGrid1.ColCount:=StringGrid1.ColCount+1;
end;procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
StringGrid1:=TStringGrid.Create(self);
with StringGrid1 do begin
Parent:=Form1;
Align:=alTop;
Height:=320;
ScrollBars:=ssHorizontal;
FixedCols:=0;
FixedRows:=0;
Options:=[goRangeSelect,goEditing,goDrawFocusSelected];
ColCount:=iColcount;
RowCount:=iRowcount;
for i:=0 to ColCount-1 do ColWidths[i]:=12;
for i:=0 to RowCount-1 do RowHeights[i]:=14;
OnSetEditText:=StringGrid1SetEditText;
end;
Button1:=TButton.Create(self);
Button1.Parent:=Form1;
Button1.Caption:='增加一列';
Button1.Left:=223;
Button1.Top:=338;
Button1.OnClick:=Button1Click;
Caption:='纵向输入';
Height:=418;
Width:=546;
Position:=poScreenCenter;
ActiveControl:=StringGrid1;
end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Button1.SetFocus;
StringGrid1.Free;
Button1.Free;
end;end.