Attilah
Attilah

Reputation: 17930

Label size changes

I have a Label, whose content is displayed by a while loop. when i display a text in label, it displays correctly. sometime minutes, the same text displayed in the same label, and the size of the text in the control changes.

Here is the code :

//Form_Load :

Thread t = new Thread(displaySentences);
t.Start();


//display sentences:
void displaySentences()
{
    while(true)
    {
       if(i>=5)
          i=0;

       label4.Text = textarray[i];
       i++;

    }

}

the size of the text in the first iteration(i=0) is different from the size of the text in the label control in the second iteration.

Upvotes: 1

Views: 1695

Answers (2)

Adam V
Adam V

Reputation: 6356

I'd be looking for something elsewhere that was modifying properties on the label4 object.

Side note - should you really be spawning a thread and having that thread mess with the UI? Chris Sells wrote a series of articles in which he explained why this was a bad idea.

Upvotes: 0

Joel
Joel

Reputation: 16655

Do you not want autosizing? Set the autosize property to false.

Upvotes: 5

Related Questions