I did that the label1 is scrolling moving from down bottom to up top and back again in a loop.
So in form1 i can give any text i want to be show and any color to color the text in.
Now instead one label i want that therw will be maximum 5labels running one after one each one with another text and another color.
So i created array of labels but what now?
This is the code so far using one label. I want to delete the current label1 from the control designer and instead using the array of labels i created.
Thanks.
So in form1 i can give any text i want to be show and any color to color the text in.
Now instead one label i want that therw will be maximum 5labels running one after one each one with another text and another color.
So i created array of labels but what now?
This is the code so far using one label. I want to delete the current label1 from the control designer and instead using the array of labels i created.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class NewsFeederControl : UserControl
{
string[] newsTF;
Label[] labelarray;
int jump = 0;
string newsTextFeed;
Color TextColor;
public NewsFeederControl()
{
InitializeComponent();
labelarray = new Label[5];
for (int i = 1; i < 5; i++)
{
//intialize new label
labelarray[i] = new Label();
labelarray[i].Size = new System.Drawing.Size(33, 33);
labelarray[i].Location = new System.Drawing.Point(i, i);
labelarray[i].Text = i.ToString();
this.Controls.AddRange(new System.Windows.Forms.Control[] {labelarray[i]});
}
TextColor = new Color();
}
private void NewsFeederControl_Load(object sender, EventArgs e)
{
}
private void NewsFeederControl_Paint(object sender, PaintEventArgs e)
{
startCustom();
}
public void newsTextFeeds(string newsText)
{
newsTextFeed = newsText;
}
public void newsTextColor(Color color)
{
TextColor = color;
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Location = new Point(label1.Location.X, label1.Location.Y - jump);
}
public void startCustom()
{
label1.Text = newsTextFeed;
label1.ForeColor = TextColor;
timer1.Interval = 50;
jump = 1;
timer1.Start();
}
private void label1_LocationChanged(object sender, EventArgs e)
{
if (label1.Location.Y <= -20)
{
label1.Location = new Point(label1.Location.X, this.Height + label1.Height);
}
}
}
}
Thanks.
Comment