Hello, I have an UserControl in my From Project,
I have this Code in the UserControl:
public partial class iktMarquee : UserControl
{
#region Properties
private string _Text = "";
private int charIndex = 0;
private Color _FontColor = Color.White;
[Description("Sets Marquee Text"), DefaultValue(""), Category("Vales"), Browsable(true)]
public string Text
{
get { return _Text; }
set { _Text = value; }
}
[Description("Sets Marquee Font Color"), Category("Appearance"), DefaultValue("White"), Browsable(true)]
public Color FontColor
{
get { return _FontColor; }
set { _FontColor = value; }
}
[Description("Sets Marquee Interval"), Category("Behavior"), DefaultValue(1000), Browsable(true)]
public int Interval
{
get { return ScrollTimer.Interval; }
set { ScrollTimer.Interval = value; }
}
#endregion
#region Control Start
public iktMarquee()
{
InitializeComponent();
}
private void iktMarquee_Load(object sender, EventArgs e)
{
}
#endregion
#region Painting
public void RePaint()
{
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(_FontColor);
System.Drawing.Graphics formGraphics = this.CreateGraphics();
formGraphics.Clear(this.BackColor);
formGraphics.DrawString(_Text.Remove(0,charIndex), this.Font, new SolidBrush(this.FontColor), 5,5);
myPen.Dispose();
formGraphics.Dispose();
}
#endregion
#region Private Functions
private void ScrollTimer_Tick(object sender, EventArgs e)
{
if (charIndex > _Text.Length)
charIndex = 0;
RePaint();
}
private void iktMarquee_Resize(object sender, EventArgs e)
{
RePaint();
}
#endregion
private void iktMarquee_Paint(object sender, PaintEventArgs e)
{
RePaint();
}
}
Then I have built the project, then set the 'Text' value in UserControl to 'Teststring '
When I Start in debug mode, the 'Text' gets reset to '', while it should be 'Teststring'.
How can I fix this?
Thanks!
Edit:
Posted full code of UserControl