如何使用memo控件
delphi吧
全部回复
仅看楼主
level 12
ymwjz 楼主
安卓手机在delphi XE10下如何使用memo控件,说要一个destory!
2017年03月07日 06点03分 1
level 12
ymwjz 楼主
目前已经解决。直接把文件复制到memo控件中的Lines中。
2017年03月07日 06点03分 2
level 12
ymwjz 楼主
但是如何控制显示的内容,就是说:有30行,只显示10-15行的内容。
2017年03月07日 06点03分 3
加滚动条三
2017年03月07日 08点03分
level 11
如果不想用滚动条,那么可以考虑另外新建一个TStringList存放完整内容,拷一部分到memo里面
2017年03月07日 09点03分 4
level 12
ymwjz 楼主
最好能给一个具体方法。
2017年03月07日 09点03分 5
level 12
ymwjz 楼主
This simple example shows how to load a file using FMX.Memo.TMemo.Lines, how to access the ninth line, and how to retrieve the number of lines in the memo control:
Memo1.Lines.LoadFromFile('myDocument.txt');
ShowMessage('The 9th line of my file is: ' + Memo1.Lines[8]);
ShowMessage('The number of lines: ' + IntToStr(Memo1.Lines.Count));
This example shows how to save two lines of memo's text into a file using the FMX.Memo.TMemo.Lines property:
Memo1.Lines.Text := '1st line' + sLineBreak + '2nd line';
Memo1.Lines.SaveToFile('NewDocument.txt');
这是从delphi XE10公司的网页上找到的。提供大家参考。
2017年03月07日 23点03分 6
level 12
ymwjz 楼主
这个简单的例子说明如何使用fmx.memo.tmemo.lines加载文件,如何访问第九线,以及如何检索在Memo控件的行数:memo1。线。LoadFromFile('mydocument .txt”);被(“第九线我的文件是:“+ memo1。线[ 8 ]);被(“行数:“+IntToStr(memo1。线。计数));这个例子展示了如何保存两行备忘录的文本使用fmx.memo.tmemo.lines属性到一个文件:memo1.lines.text:=“第一线”+ slinebreak +“第二线”;memo1。线。SaveToFile('newdocument .txt”);
以上百度翻译软件翻译
这是从Delphi公司的网页上找到的提供大家参考前后。
2017年03月07日 23点03分 7
level 12
ymwjz 楼主
第一个例子说明如何使用fmx.memo.tmemo.lines加载文件,如何访问第九条记录,以及如何检索在Memo控件的行数:
2017年03月07日 23点03分 8
level 12
ymwjz 楼主
第二个例子展示了如何保存两行备忘录的文本到一个文件中使用fmx.memo.tmemo.lines
2017年03月07日 23点03分 9
level 12
ymwjz 楼主
FMX.Memo.TCustomMemo.Text
Up to Parent: TCustomMemo
Delphi
property Text: string read GetText write SetText;
C++
__property System::UnicodeString Text = {read=GetText, write=SetText};
Contents [hide]
1 Properties
2 Description
2.1 See Also
2.2 Code Examples
Properties
TypeVisibilitySourceUnitParent
propertypublic
FMX.Memo.pas
FMX.Memo.hpp
FMX.MemoTCustomMemo
Description
Represents the entire text displayed in the memo control.
Note: The visibility for Text is Public. Thus, Text is not available in the Object Inspector at design time. For manipulating the text in a TMemo, you should use FMX.Memo.TMemo.Lines, which is available at design time in the Object Inspector.
2017年03月07日 23点03分 10
level 12
ymwjz 楼主
ShowMessage('The number of lines:' + IntToStr(Memo1.Lines.Count));
You can add new lines:
Memo1.Lines.Append('New text to append at the end of memo');
You can delete lines:
Memo1.Lines.Delete(0); // Deletes the fist line from memo
You can replace a line with a new string:
Memo1.Lines[8] := 'Replace 9th line with this string';
2017年03月07日 23点03分 11
level 12
ymwjz 楼主
RAD Studio Code Examples and Sample Applications
Contents [hide]
1 Browsing the Documentation
1.1 Code Examples
1.2 Sample Applications (Demos) That Accompany RAD Studio
1.3 Code Examples and Sample Applications Sorted by Functionality
1.4 Code Examples and Sample Applications Sorted by Version or Language
2 Projects in SourceForge
3 Providing Feedback
Browsing the Documentation
This documentation volume contains code examples for commonly used members of the RAD Studio frameworks and libraries.
Code Examples
An index of all available code examples.
Sample Applications (Demos) That Accompany RAD Studio
An index of all available sample applications.
Code Examples and Sample Applications Sorted by Functionality
Code examples and sample applications sorted by the units and members that they use.
Code Examples and Sample Applications Sorted by Version or Language
You can browse code examples and sample applications by:
Version of RAD Studio when they were added.
Programming language:
Delphi.
C++.
Projects in SourceForge
RAD Studio application samples in the SourceForge Subversion repository
PowerPDF by Nick Hodges and Roman Kassebaum
TextScrubber by Nick Hodges
TSmiley by Nick Hodges
Providing Feedback
To provide comments, request improvements, make suggestions or even submit code examples that you would like to post on this wiki or in SourceForge, contact [email protected].
2017年03月07日 23点03分 13
level 12
ymwjz 楼主
以上标题:RAD Studio代码示例和示例应用程序
2017年03月07日 23点03分 14
level 12
ymwjz 楼主
以下是网页上搜索到的,请参考。
Edit和MaskEdit组件都只能编辑单行文本,Delphi的Memo组件提供了多行文本的编辑功能。下面解释Memo组件常用的属性。
  Lines:这是Memo组件最常用,也是最有用的属性,它用来显示和保存Memo组件中的内容。
  Scrollbar:很多组件都有这个属性。用于设定组件有否滚动条。它有四个值:SSNone表示既无水平滚动条,也无垂直滚动条;SSHorizontal表示只有水平滚动条;SSVertal表示只有垂直滚动条;SSBoth表示两者都有。当用户要显示的文本或其它的内容较多时,建议选用SSBoth。
  WordWrap:用于设定Momo组件是否具有自动折行功能。
  WantTabs:这个属性只在Memo、RichEdit和DBMemo组件中使用。通常在切换当前焦点控件时,我们通常使用Tab键。但在上述三种组件中,编辑文本时常用Tab键来跳过若干个空格使文本对齐,这时就会有冲突。所以应将WantTabs设置为True,这样子在组件内就可以使用Tab键来编辑文本。
Memo组件常用的方法:
  1. 使用剪贴板(Clipboard)
  我们可以使用CutToClipboard、CopyToClipboard和PastFromClipboar这三种方法,实现将Memo组件中被选择文本剪切或复制到剪贴板上,以及将剪切板上的内容粘贴到Memo组件中。
  将Memo中的选中文本剪切到剪贴板的语句如下:
  if Memo1.SelLength>0 then
  2. 文本的添加
  利用Lines属性,可以增加、删除一行文本,也可以移动一行文本。下面的代码将文本添加到Memo中的最后一行:
  Memo1.Lines.Add('将文本添加到Memo中’);
  3. 文件的保存和装载
  我们可以将Memo组件中的文本保存成文本文件,也可以将文本文件装载到Memo中。这须要配合使用SaveDialog组件和OpenDialog组件。将Memo中的文本保存为文件的语句为:
  If SaveDialog1.Execute then   //打开保存对话框
  Memo1.Lines.SaveToFile(SaveDialog1.FileName);  //保存为文件
上边的语句先打开保存对话框,然后将Memo中的文本保存到一个文件中,文件名为我们在SaveDialog中输入的文本。
  在Memo中装载文本文件的语句为:
  if Opendialog1.Execute then
  Memo1.Lines.LoadFile(Opendialog1.FileName);
执行上边语句将打开Opendialog对话框,然后将选中的文本文件装载到Memo中。
下面我们使用Memo组件的这些特性制作一个简单的文本编辑器,可以实现文本的拷贝复制,并可以进行文本的保存和装载。当然程序的功能还很简单,我们还可以进一步扩展。这里是入门教程,所以不宜太复杂。
  程序的界面如下图所示:
程序代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Lines.Add('在末端添加文本');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Lines.Text:='这里是Memo组件示例';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if Memo1.SelLength>0 then
Memo1.CutToClipboard;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if savedialog1.Execute then
memo1.Lines.SaveToFile(savedialog1.FileName);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
if Opendialog1.Execute then
memo1.Lines.LoadFromFile(opendialog1.FileName);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Memo1.SelLength>0 then
Memo1.CopyToClipboard;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if Memo1.SelLength=0 then
Memo1.PasteFromClipboard;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
close;
end;
end.
2017年03月07日 23点03分 15
level 11
支持一下
2017年03月08日 23点03分 16
1