テキストボックスについて

この章ではテキストボックスについて解説します。

.NET Frameworkにおいてテキストボックスを表すクラスはTextBoxです。
下記はテキストボックスを使ったサンプルコードです。

using System;
using System.Drawing;
using System.Windows.Forms;

public class Sample
{
    public static void Main(String[] args)
    {
        Form f = new Form();
        TextBox textBox = new TextBox();
        textBox.Location = new Point(10, 10);
        f.Controls.Add(textBox);
        Application.Run(f);
    }
}

サンプルを実行するとウィンドウが表示され、その中にテキストボックスが表示されます。

TextBoxクラスの主なプロパティ

表示文字列

テキストボックスに表示する文字列を参照・設定するにはTextプロパティを使用します。

表示位置

テキストボックスの位置を設定するにはLocationプロパティを設定します。
Locationプロパティの型はPointクラスになります。



inserted by FC2 system