public static void addResultToFlowLayoutPanel(FlowLayoutPanel flowLayoutPanel, object returnData, Color color) { /*var result = new Panel { BackColor = color, Height = 10, Text = ((returnData != null) ? returnData.ToString() : "") };*/ //flowLayoutPanel.ts_AddControl(result); //if (returnData != null) //{ var textBox = new TextBox { Width = (flowLayoutPanel.Width > 20) ? flowLayoutPanel.Width - 22 : flowLayoutPanel.Width, // 6 works except when there are scrool bars, WordWrap = false, Multiline = true, BackColor = color, ScrollBars = ScrollBars.None }; var heigthItem = 14; var heigthPad = 4; if (returnData == null) { textBox.Text = ""; //"[null]"; } else if (returnData is List<string>) { var stringList = (List<string>) returnData; textBox.Lines = stringList.ToArray(); textBox.Height = heigthItem*stringList.Count + heigthPad; } else { var rawText = returnData.ToString(); var splittedText = rawText.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); if (splittedText.Length == 0) textBox.Text = ""; else { textBox.Lines = splittedText; textBox.Height = heigthItem*splittedText.Length + heigthPad; } } //Text = // textBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; flowLayoutPanel.add_Control(textBox); // } // flowLayoutPanel.Controls.Add(okPanel); }