private void SetItems(IEnumerable <string> text) { var graphics = ActionList.CreateGraphics(); var text_array = text.ToArray(); ActionList.Items.AddRange(text_array); int width = 0; int height = 0; foreach (var item in text_array) { var size = graphics.MeasureString(item, ActionList.Font); width = Math.Max(width, (int)Math.Ceiling(size.Width)); height = Math.Max(height, (int)Math.Ceiling(size.Height)); } var box_size = new Size(width + 20, height * Math.Min(10, text_array.Length)); var full_size = new Size(box_size.Width, box_size.Height + InfoPanel.Height); ActionList.MinimumSize = box_size; ActionList.ItemHeight = Math.Max(1, height); this.MinimumSize = full_size; this.Size = full_size; }