Note that there are some explanatory texts on larger screens.

plurals
  1. POc# flow layout labels got stuck
    primarykey
    data
    text
    <p>I have a form with two custom panels and I'm adding some labels to them and in the end i want they to scroll from the right to the left but they are just stucking in the same position. There is a screenshot of what i have <img src="https://i.stack.imgur.com/xUNSi.png" alt="enter image description here"> There are two panels and the 4 labels and they just stay stuck in there... This is the code in my form:</p> <pre><code> private MyPanel topPanel; // the red bar private MyPanel botPanel; // the white bar public SmsBar() { InitializeComponent(); this.Width = 500000; this.Location = new Point(x, y); topPanel = new MyPanel(System.Drawing.Color.White, System.Drawing.Color.Red, (new Font("Tahoma", 10, FontStyle.Bold))); botPanel = new MyPanel(System.Drawing.Color.Black, System.Drawing.Color.White, (new Font("Tohama", 10, FontStyle.Regular))); msgPanel.Controls.Add(topPanel); adPanel.Controls.Add(botPanel); botPanel.addMsg(new MsgForDisplay(0, AppData.getInstance().getAdMsg())); botPanel.addMsg(new MsgForDisplay(0, AppData.getInstance().getAdMsg2())); topPanel.addMsg(new MsgForDisplay(0, "test top")); topPanel.addMsg(new MsgForDisplay(0, "test top 2")); adPanel.Refresh(); msgPanel.Refresh(); } </code></pre> <p>And there is some code of my custom panel (<strong>Constructor</strong>):</p> <pre><code> public MyPanel(Color corLabel, Color back, Font text){ this.color = corLabel; this.backg = back; this.textFont = text; this.Width = 500000; txt= new LinkedList&lt;string&gt;(); msgs = new LinkedList&lt;MsgForDisplay&gt;(); labels = new LinkedList&lt;Label&gt;(); var it = labels.GetEnumerator(); var it2 = msgToRemove.GetEnumerator(); this.FlowDirection = FlowDirection.LeftToRight; this.BackColor = backg; this.Size = new Size(500000, 35); this.Refresh(); } </code></pre> <p><strong>The running:</strong></p> <pre><code> public void run() { while (true) { var it = labels.GetEnumerator(); while(it.MoveNext()){ Label lb = it.Current; if (lb.Location.X + lb.Width &lt; 0) { if (msgsRemover.Contains(lb.Text.ToString())) { labels.Remove(lb); this.Invoke(new MethodInvoker(() =&gt; { this.Controls.Remove(lb); })); msgsRemover.Remove(lb.Text.ToString()); } else { // if there is no message to be removed, they will just continue // going to the end of the queue this.Invoke(new MethodInvoker(() =&gt; { this.Controls.Remove(lb); })); this.Invoke(new MethodInvoker(() =&gt; { this.Controls.Add(lb); })); } this.Invoke(new MethodInvoker(() =&gt; { this.Refresh(); })); } this.Invoke(new MethodInvoker(() =&gt; { lb.Location = new Point(lb.Location.X - 3, lb.Location.Y); })); } System.Threading.Thread.Sleep(30); } } </code></pre> <p>And the <strong>addMsg</strong> function:</p> <pre><code> public void addMsg(MsgForDisplay msg) { Label lbl = new Label(); lbl.Text = ("- " + msg.getText() + " -"); lbl.ForeColor = color; lbl.Font = textFont; lbl.BackColor = backg; lbl.Visible = true; lbl.AutoSize = true; labels.AddLast(lbl); this.Controls.Add(lbl); } </code></pre> <p>I guess that the problem must be with the layouts but I doesn't really know what I should use... Thank you in advance for the help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload