public static CheckBoxPP AddCheckBox(string text, Font font, int top, int left, int width, AnchorStyles anchors, Panel panel, int tabidx, int selidx) { CheckBoxPP checkBox = new CheckBoxPP(); checkBox.Anchor = anchors; checkBox.Font = font; checkBox.TabIndex = tabidx; checkBox.SelectedIndex = selidx; checkBox.Name = "radioPreview" + tabidx.ToString(); checkBox.Text = Tools.FixPanelText(text); int height = Tools.GetLabelHeight(text, font, width - 20); // The '20' accounts for the checkbox and the gap afterwards checkBox.Height = height; checkBox.Width = width; checkBox.Left = left; checkBox.Top = top; checkBox.TextAlign = ContentAlignment.TopLeft; checkBox.CheckAlign = ContentAlignment.TopLeft; panel.Controls.Add(checkBox); checkBox.Click += new System.EventHandler(Preview_Event); return(checkBox); }
public static CheckBoxPP AddCheckBox(string text, Font font, int top, int left, int width, Panel panel, int selidx) { CheckBoxPP checkBox = new CheckBoxPP(); checkBox.Font = font; checkBox.ForeColor = Color.Blue; checkBox.LabelForeColor = Color.Black; checkBox.SelectedIndex = selidx; checkBox.Location = new Point(left, top); checkBox.Text = text; int width2 = Tools.GetLabelWidth(text, font); int numlines = 1; if (width2 < width) { numlines = width2 / width + 1; // ex. 2.7 -> 3 } else { numlines = (int)(((float)width2 / width) + 0.25) + 1; // ex. 2.75 -> 4 } int height = 1 + (int)(font.Size * 2 * numlines); checkBox.LabelWidth = width; // This actually sets the width of the LinkLabel checkBox.LabelHeight = height; // Ditto re the height panel.Controls.Add(checkBox); checkBox.Click += new System.EventHandler(PanelChoices_Event); checkBox.LinkLabelClick += new EventHandler(PanelChoices_Event); return(checkBox); }