Free Support Forum - aspose.com

Radio button is not selected

Hi,

I am making radio buttons groups and i want to select particular radio button in groups, but its not selecting and linked cell value is changing with 0.

please have a look my code, and guide...

private void CreateRadios(global::DataModel.Reporting.Attribute attr, Worksheet wrk)

{

List<ChoiceList> choiceLists = attr.ChoiceLists;

AttributeValue av = attr.AttributeValues[0];

int noofRadios = choiceLists.Count;

int FirstRadioButtonRowIndex = CurrentRow;

int selectedRadio = 0;

Aspose.Cells.Drawing.GroupBox _box = wrk.Shapes.AddGroupBox(CurrentRow, 0, ColumnIndexC, 0, (20 * noofRadios), Convert.ToInt32(wrk.Cells.GetColumnWidthPixel(ColumnIndexC)));

_box.IsHidden = true;

Aspose.Cells.Drawing.RadioButton[] radios = new Aspose.Cells.Drawing.RadioButton[noofRadios];

Aspose.Cells.Drawing.Shape[] shapeobjects1 = new Aspose.Cells.Drawing.Shape[noofRadios + 1];

shapeobjects1[0] = _box;

for (int i = 0; i < noofRadios; i++)

{

SetCurrentRowstyle();

radios[i] = wrk.Shapes.AddRadioButton(CurrentRow, 0, ColumnIndexC, 0, 17, Convert.ToInt32(wrk.Cells.GetColumnWidthPixel(ColumnIndexC)));

Ws.Cells[CurrentRow, ColumnIndexD].PutValue(choiceLists[i].Label);

//radios[i].LinkedCell = CellsHelper.CellIndexToName(FirstRadioButtonRowIndex, ColumnIndexB);

radios[i].LinkedCell = "B" + (FirstRadioButtonRowIndex + 1).ToString();

shapeobjects1[i + 1] = radios[i];

if (choiceLists[i].DefaultChoice || (choiceLists[i].Label != null && choiceLists[i].Label.ToUpper() == av.Flattened.ToUpper()))

{

selectedRadio = (i + 1);

}

CurrentRow++;

}

wrk.Cells["B" + (FirstRadioButtonRowIndex + 1).ToString()].PutValue(selectedRadio);

//wrk.Cells[CellsHelper.CellIndexToName(FirstRadioButtonRowIndex, ColumnIndexB)].PutValue(selectedRadio);

wrk.Shapes.UpdateSelectedValue();

}

Hi,

Please also create a sample xlsx file manually using Ms-Excel that you want to see as a desired output and post here.