Selected

OptionButtonControl.Selected property

Gets or sets a boolean value indicating either this OptionButtonControl is selected or not.

public bool Selected { get; set; }

Remarks

Note, this property allows you to select multiple items in a group of OptionButtonControl with the same GroupName. It is up to you to take care of deselecting a previously selected item when you make this OptionButtonControl selected.

Examples

Shows how to select radio button.

Document doc = new Document(MyDir + "Radio buttons.docx");

Shape shape1 = (Shape)doc.GetChild(NodeType.Shape, 0, true);
OptionButtonControl optionButton1 = (OptionButtonControl)shape1.OleFormat.OleControl;
// Deselect selected first item.
optionButton1.Selected = false;

Shape shape2 = (Shape)doc.GetChild(NodeType.Shape, 1, true);
OptionButtonControl optionButton2 = (OptionButtonControl)shape2.OleFormat.OleControl;
// Select second option button.
optionButton2.Selected = true;

Assert.AreEqual(Forms2OleControlType.OptionButton, optionButton1.Type);
Assert.AreEqual(Forms2OleControlType.OptionButton, optionButton2.Type);

doc.Save(ArtifactsDir + "Shape.SelectRadioControl.docx");

See Also