Autor Beitrag
Ritzeratze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101



BeitragVerfasst: Sa 01.02.14 20:57 
Moin

ich möchte ein Lauftext bauen. von Koordinate 0 bis 300 durchs Formular. Das soll min 10 mal laufen. Pro Lauf wird das Label um 1 px nach unten verschoben. Habe dasa Form mit einem Timer versehen, der den Text alle 5 sek nach unten verschiebt. Das

Mein Code bis jetzt.

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Labelwanderung
{
  public partial class frmLabelwanderung : Form
  {
    public frmLabelwanderung()
    {
      InitializeComponent();
    }

    private void btnStart_Click(object sender, EventArgs e)
    {
      timer.Enabled = true;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
      int x, y, width, height = 0;
      for (y = 0; y < 300; y++)
        lblMove.SetBounds(01000);
    }
  }
}


Irgendwie bin ich da ein wenig auf dem Holzweg. Kann mir jemand einen Tipp geben?

Gruss Ritze

Moderiert von user profile iconTh69: Code- durch C#-Tags ersetzt
Moderiert von user profile iconChristian S.: Topic aus C# - Die Sprache verschoben am Sa 01.02.2014 um 22:28
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4807
Erhaltene Danke: 1061

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Sa 01.02.14 21:13 
Hallo,

SetBounds(01000) in einer Schleife ergibt wohl keinen Sinn. ;-)

Für die Änderung der Position nimm
ausblenden C#-Quelltext
1:
lblMove.Location = new Point(lblMove.Left, y);					

Damit du aber den Verlauf siehst (und nicht nur das Endergebnis) mußt du pro Tick jeweils die Variable verändern und die Position damit setzen. Dies bedeutet, daß die Variable y dann eine Klassenvariable (Member) sein muß!
Ritzeratze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101



BeitragVerfasst: Sa 01.02.14 21:36 
Moin Th69,

Danke für den Tipp. das heißt, dass ich lblMove.Laoation dem Tick Event zufügen muss? und wie erfolgt dann die Erhöhung der Y Koordinate? Das kann ich meines Erachtens doch nur in einer Schleife realisieren?

Guss Ritze
Ritzeratze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101



BeitragVerfasst: Sa 01.02.14 22:50 
Oh man , vielleicht sollte man das Bier weglassen.
Ich habe das Problem erledigt. Bin auf dem völlig falschen Holzdampfer gewesen.

DaAnke nochmals für die Antwort.

Gruss
Ritze