(C#)表格布局面板导致输出异常

(C#)表格布局面板导致输出异常,c#,winforms,visual-studio,chat,C#,Winforms,Visual Studio,Chat,我正试图用以下代码制作一个类似于聊天的图形程序 private void Form1_Load(object sender, EventArgs e) { LogLoader(); cellNo +=1; dateLoader(DateTime.Today.ToString("dd MMMM yyyy")); if (datestamp.Text == DateTime.Today.ToString("dd MMMM yy

我正试图用以下代码制作一个类似于聊天的图形程序

private void Form1_Load(object sender, EventArgs e)
    {

        LogLoader();
        cellNo +=1;
        dateLoader(DateTime.Today.ToString("dd MMMM yyyy"));
        if (datestamp.Text == DateTime.Today.ToString("dd MMMM yyyy"))
        {
            dateLoader("Today");
        }
        tableLayoutPanel1.Controls.Add(datestamp, 0, cellNo);
        LogCreator();
        inputBubbleLoader("Hello... Testing this", DateTime.Now.AddDays(1).ToString("hh:mm:ss"));
        tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));
        tableLayoutPanel1.Controls.Add(input,0,cellNo+1);
    }
    public void inputBubbleLoader(String inputText , String time)
    {
        Panel input = new Panel();

        inputLabel.Text = inputText;
        inputLabel.Font = new Font("Ariel", 10);
        Size size = TextRenderer.MeasureText(inputText,inputLabel.Font);
        inputLabel.Parent = input;
        inputLabel.Location = new Point(input.Location.X+5, input.Location.Y+5);
        timestamp1.Text = time;

        timestamp1.Parent = input;
        Size tsize = TextRenderer.MeasureText(timestamp1.Text, timestamp1.Font);
        timestamp1.Location = new Point(input.Location.X + input.Width - tsize.Width-5, input.Location.Y+input.Height-(tsize.Height)-5);

        inputLabel.MaximumSize = new Size(tableLayoutPanel1.Width, 0);
        input.AutoSize = true;
        inputLabel.AutoSize = true;
        timestamp1.AutoSize = true;
        cellNo += 1;
        tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));
        tableLayoutPanel1.RowStyles[cellNo].Height = input.Height;
        tableLayoutPanel1.RowStyles[cellNo].SizeType = SizeType.AutoSize;
        tableLayoutPanel1.Controls.Add(input, 0, cellNo);
    }
    public void dateLoader(string date)
    {
        datestamp.Text = date;

        tableLayoutPanel1.RowStyles[cellNo].Height = datestamp.Height;
        tableLayoutPanel1.RowStyles[cellNo].SizeType = SizeType.AutoSize;
        tableLayoutPanel1.Controls.Add(datestamp,0,cellNo);
    }

    public void LogLoader()
    {

        string[] lines = File.ReadAllLines(@"C:\Users\Attey\Desktop\LogSave.txt");
        foreach(string line in lines)
        {
            if (String.IsNullOrWhiteSpace(line))
            {
                continue;
            }
            else if (line.StartsWith("--"))
            {
                dateLoader(line.Substring(line.IndexOf("-- [[")+1));
            }
            else if (line.StartsWith("["))
            {
                inputBubbleLoader(line.Substring(line.IndexOf(": ")), line.Substring(line.IndexOf("["), 8));

            }              
        }
    }
}
LogLoader不加载写入的消息,只加载测试消息, 尽管程序成功地写入了文本文件。
每次我运行程序时,表布局都会有一些小的/大的变化

没有人喜欢回答代码转储。尤其是当至少60%的代码完全没有必要演示问题时。我建议您删除所有不必要的与GUI相关的内容,甚至可以将其转换为CUI。如果你照我现在告诉你的去做,我相信你会发现问题的。即使没有,你也会有一个很好的机会,你可以问心无愧地在这里发布你已经做了所有你能做的事情。但是问题在于GUI部分。谢谢你告诉我。我已经修剪了这篇文章。@SPSingh你真的做了一个MCVE吗,或者你刚刚删除了一些代码,这样样本看起来就不会那么恶心了?就我个人而言,我不会赌前者。用尽可能小的代码隔离问题。有时甚至有必要从头开始创建演示。好的,我将在下一个版本中尽我最大的努力。它的MCVE现在无法进一步减少它,因为我不确定是哪个部分导致了问题