public static RadioButtonPP AddRadioButton(string text, Font font, int top, int left, int width, AnchorStyles anchors, Panel panel, int tabidx, int selidx) { RadioButtonPP radioBut = new RadioButtonPP(); radioBut.Anchor = anchors; radioBut.Font = font; radioBut.TabIndex = tabidx; radioBut.SelectedIndex = selidx; radioBut.Name = "radioPreview" + tabidx.ToString(); radioBut.Text = Tools.FixPanelText(text); int height = Tools.GetLabelHeight(text, font, width - 10); radioBut.Height = height; radioBut.Width = width; radioBut.Left = left; radioBut.Top = top; radioBut.TextAlign = ContentAlignment.MiddleLeft; radioBut.CheckAlign = ContentAlignment.TopLeft; panel.Controls.Add(radioBut); radioBut.Click += new System.EventHandler(Preview_Event); return(radioBut); }
public static RadioButtonPP AddRadioButton(string text, Font font, int top, int left, int width, Panel panel, int selidx) { RadioButtonPP radioBut = new RadioButtonPP(); radioBut.Font = font; radioBut.ForeColor = Color.Blue; radioBut.LabelForeColor = Color.Black; radioBut.SelectedIndex = selidx; radioBut.Location = new Point(left, top); radioBut.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); // Larger height factor necessary with radioButtons it seems radioBut.LabelWidth = width; // This actually sets the width of the LinkLabel radioBut.LabelHeight = height; // Ditto re the height panel.Controls.Add(radioBut); radioBut.Click += new System.EventHandler(PanelChoices_Event); radioBut.LinkLabelClick += new EventHandler(PanelChoices_Event); return(radioBut); }