Scenes
effect
Note:
Blog home page:
https://blog.csdn.net/badao_liumang_qizhi
public concern number of
programs overbearing ape
acquisition-related programming e-books, tutorials and push for free download.
achieve
Create a Form, form background color set to black, and then drag a LIstBox for accessing the contents to be scrolled, and then drag a Timer component
Right-click the Timer component to set its properties
Enabled property set to true, it indicates available, Interval represents the time interval of 0.2 seconds.
Then there is a Timer Tick event, the specific representation to be performed, i.e., every 0.2 seconds to perform the operation.
Then set the ListBox properties and content to be scrolled
this.listBox1.BackColor = System.Drawing.SystemColors.WindowText; this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.listBox1.ForeColor = System.Drawing.SystemColors.InactiveCaption; this.listBox1.FormattingEnabled = true; this.listBox1.ItemHeight = 12; this.listBox1.Items.AddRange(new object[] { "逆战", "演唱:张杰", "在这个风起云涌的战场上", "暴风少年登场", "在战胜烈火重重的咆哮声", "喧闹整个世界", "硝烟狂飞的讯号", "机甲时代正来到", "热血逆流而上", "战车在发烫", "勇士也势不可挡", "come on逆战 逆战来也", "王牌要狂野", "闯荡宇宙摆平世界", "Oh 逆战 逆战狂野", "在这个风起云涌的战场上", "暴风少年登场", "在战胜烈火重重的咆哮声", "喧闹整个世界", "硝烟狂飞的讯号", "机甲时代正来到", "热血逆流而上", "战车在发烫", "勇士也势不可挡", "come on逆战 逆战来也", "王牌要狂野", "闯荡宇宙摆平世界", "Oh 逆战 逆战狂野" }); this.listBox1.Location = new System.Drawing.Point(56, 377); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(400, 480); this.listBox1.TabIndex = 0;
然后在窗体的Load事件中,将ListBox置于窗体最底部,即设置其距离顶部的距离为窗体的高度。
然后再上面设置的每隔0.2秒执行的方法中进行判断,如果ListBox距离顶部的位置小于负的自己的高度,即一次轮播到顶,再重新设置其距离顶部的距离为窗体高度,否则就会将ListBox举例顶部的距离减去5。
关键代码
private void Form1_Load(object sender, EventArgs e) { listBox1.Top = this.Height; this.Focus(); } private void timer1_Tick(object sender, EventArgs e) { if (listBox1.Top < -listBox1.Height) { listBox1.Top = this.Height; } listBox1.Top = listBox1.Top - 5; this.Focus(); }
代码下载
https://download.csdn.net/download/BADAO_LIUMANG_QIZHI/12025689