LoginSignup
0
0

More than 1 year has passed since last update.

C#でテロップソフトを作る。(labelを流す)

Last updated at Posted at 2022-05-23

こんにちは。みらいです。

C# 🔰初心者向けの記事を書きます。

今日はC#のFormでテロップソフトを作ります。(labelを流す)

サンプルはGithubに置いています。

まずはFormの上にPanelを置きましょう。
Panelの上にlabelを流します。↓
スクリーンショット 2022-05-23 212456.png
そのPanelの上にlabelを配置します。こんな感じ↓(置き方にこだわりはない)
スクリーンショット 2022-05-23 212617.png
次にTimerを用意します。
Timerの設定はこれ↓(名前は何でもいい)
スクリーンショット 2022-05-23 212744.png

次はコードを書いていきましょう。

private void TelopTimer_Tick(object sender, EventArgs e)
{
 Mainlabel.Left += -2;
 if (Mainlabel.Right < 0)  Mainlabel.Left = this.ClientSize.Width - Mainlabel.Right;
}

非常にわかりずらい解説(しらんけど)

Mainlabel.Left += -2

↑「Mainlabel」の部分はlabelの名前のこと。「-2」の部分でテロップ速度を設定できます。

if (Mainlabel.Right < 0)  Mainlabel.Left = this.ClientSize.Width - Mainlabel.Right;

↑このif文は「もしlabelが一番左へ行ったら右にlabelを戻す」という処理をします。

はい終わりです。
はじめての記事で何書けばいいかわからなかったので適当に書いてみました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0