我想实现支持显示从上往下书写的文字(如:蒙古文)的控件。想了一些办法,不过觉得有点复杂。能否通过改改控件属性来实现这个功能啊?哪位高人能指点一下?控件必须是内容可编辑控件,如:edit,memo,richedit等。
我想到的办法就是限制一个memo的行数,让它可以向有方向伸展,然后通过一些计算,把字符串拆分成字符,一个一个的显示。如行数是10,第一行第一个字符显示字符串第一个字符,第一行第二个字符显示字符串第十一个字符.....不过这样做真的有点复杂。哪位高人有更好的办法啊???

解决方案 »

  1.   

    http://it.china-b.com/cxsj/delphi/20090820/146877_1.html
      

  2.   

    gdi+绘图完美支持,LZ可以自己做一个控件嘛
      

  3.   

    刚看了下和1L思路差不多,简单的说,一个panel一个edit,鼠标点击时edit显示,可以进行编辑,回车或者焦点离开时edit隐藏,然后按照edit的内容使用绘图技术把文字画在panel上
      

  4.   

    1楼:这样貌似只能解决显示问题,内容多了,换行还要判断...现在的需求是,能够在edit里面编辑,就跟处理英文,中文一样...2楼:我自己写一个控件的话,有点划不来。那点辛苦费...写控件比起我上面的那个思路,可能还比较复杂呢。
      

  5.   

    新建工程、双击窗体、把下面代码覆盖unit1的所有内容:
    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.
      

  6.   

    问题解决了。用了一个activx控件。名字叫HuRiTaiText.ocx。需要的朋友可以再资源里找。