header
CodePanic! > C#.NET Tips > 今ここ

■StatusStrip(ステータスバー)の使い方

StatusStrip(ステータスバー)を使うには
StatusStripコントロールをFormにドロップして配置します。

status.jpg(33928 byte)

これだけで、Form上でステータスバーが表示されます。
上の画像でもわかるように▼ボタンをクリックすると
ステータスバーに追加可能なコントロールの一覧が表示されます。

ここでは簡単なStatusLabelコントロールを選んでみます。

配置されたButtonをクリックされたら
StatusLabelのテキストを変更するサンプルコードは次のようになります。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.toolStripStatusLabel1.Text = "ボタンが押されました";
        }
    }
}

status_button.jpg(16696 byte)



Copyright © 2008.07 - shougo suzaki