A memo is text-based control that uses the same
functionality as a text box except that it can display its text on
multiple lines, can accept the Tab key, can allow the user to move to the
next line when pressing Enter, can wrap text, and can display scroll bars.
To create a memo in MS .Net application, use the
TextBox class. |
|
- Start Microsoft Visual Studio .NET
- On the Start Page, click New Project (alternatively, on the main menu, you can
click File -> New -> Project...)
- On the New Project dialog box, in the Project Types tree list, click
Visual C++ Projects
- In the Templates list, click Managed C++ Empty Project
- In the Name edit box, replace the <Enter name> content with Memo
Example
- In the Location combo box, accept the suggestion or type your own.
If you don't have any, type C:\Programs\MSVC.NET
- Click OK
- On the main menu, click Project -> Add New Item...
- In the Add New Item dialog box, in the Templates list, click C++
File
- In the Name box, replace <Enter name> with Main and click OK
- Replace the contents of the empty file with the following:
#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
__gc class SimpleForm : public Form
{
public:
SimpleForm();
private:
// Declare a pointer to TextBox
TextBox *Editor;
};
SimpleForm::SimpleForm()
{
this->Text = S"Editor";
this->Size = Point(600, 420);
// Initialize the declared TextBox variable
Editor = new TextBox();
// Allow the user to press Enter
// to move to the next line
Editor->AcceptsReturn = true;
// Allow the user to press TAB key to create indentation
// in the memo or for any other reason
Editor->AcceptsTab = true;
// Set the Multiline property to true
Editor->Multiline = true;
// Add a vertical scroll bar by default to the memo
Editor->ScrollBars = ScrollBars::Vertical;
// Allow the memo to wrap text
Editor->WordWrap = true;
// Let the memo occupy the whole client area
Editor->Dock = DockStyle::Fill;
// After creating the control, add it to the form
this->Controls->Add(Editor);
}
int __stdcall WinMain()
{
SimpleForm * FM = new SimpleForm();
Application::Run(FM);
return 0;
}
|
- Press Ctrl + F5 to test the application
|
|
|