We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Grouping radio buttons row wise

How to group a Radio buttons row wise ,i have 3 radio button in 4th row and 3 radio button in 8th row, now i have to make group 4th row radio buttons as group 1 and 8th row radio button as group 2

static void Main(string[] args)
{
string root = @“D:\New folder”;
System.IO.DirectoryInfo di = new DirectoryInfo(root);
if (Directory.Exists(root))
{
foreach (FileInfo file in di.GetFiles())
{
file.Delete();
}
// Directory.Delete(root);
}

        Workbook excelbook = new Workbook();

        // Worksheet objtempworksheet = null;
        //int Row = 3;
        List<Aspose.Cells.Drawing.GroupShape> grp = new List<GroupShape>();
        List<Aspose.Cells.Drawing.Shape[]> sh = new List<Shape[]>();
       
        for (int Row = 3; Row <= 8; Row++)
        {
            Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[4];
            int column = 1;
            
           
            //}

            Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(Row, 0, column, 0, 21,150);

            box.Name = "Example";
            //box.HasLine.
            //box.IsHidden = true;
            int j = 0; ;


            List<Aspose.Cells.Drawing.RadioButton> listradio = new List<Aspose.Cells.Drawing.RadioButton>();
            for (int i = 1; i <= 3; i++)
            {
                listradio.Add(excelbook.Worksheets[0].Shapes.AddRadioButton(Row, 0, column, 0, 30,40));
                column++;
            }
            Row++; Row++; Row++; Row++;
            column++;


            
            shapeobjects[j] = box;
             j++;
            foreach (Aspose.Cells.Drawing.RadioButton item in listradio)
            {
                shapeobjects[j] = item;
                j++;
            }
            //sh.Add(shapeobjects);
            grp.Add(excelbook.Worksheets[0].Shapes.Group(shapeobjects));
            //Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects);
        }
       // Aspose.ce
        excelbook.Worksheets[0].IsGridlinesVisible = false;
        // Restricting users to edit contents of the worksheet
        excelbook.Worksheets[0].Protection.AllowEditingContent = true;
        // Restricting users to edit objects of the worksheet
        excelbook.Worksheets[0].Protection.AllowEditingObject = true;
        // Restricting users to edit scenarios of the worksheet
        excelbook.Worksheets[0].Protection.AllowEditingScenario = false;
        excelbook.Worksheets[0].Protection.AllowDeletingRow = false;
        excelbook.Worksheets[0].Protection.AllowDeletingColumn = false;
        excelbook.Worksheets[0].Protection.AllowInsertingColumn = false;
        excelbook.Worksheets[0].Protection.AllowInsertingRow = false;
        excelbook.Save("D:\\New folder\\" + "book1.xls");
        // The code provided will print ‘Hello World’ to the console.
        // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
        //string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        //string root = @"D:\New folder";
        // System.IO.DirectoryInfo di = new DirectoryInfo(root);
        //if (Directory.Exists(root))
        //{
        //    foreach (FileInfo file in di.GetFiles())
        //    {
        //        file.Delete();
        //    }
        //   // Directory.Delete(root);
        //}

        //Workbook excelbook = new Workbook();
        //excelbook.Worksheets[0].IsGridlinesVisible = false;
        //excelbook.Worksheets[0].Protection.AllowDeletingRow = false;
        //excelbook.Worksheets[0].Protection.AllowDeletingColumn = false;
        //excelbook.Worksheets[0].Protection.AllowInsertingColumn = false;
        //excelbook.Worksheets[0].Protection.AllowInsertingRow = false;
        //// Worksheet objtempworksheet = null;
        //int row = 1;
        //for (int ques = 1; ques <= 2; ques++)
        //{

        //    //}

        //        Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(row, 0, 1, 0, 100, 250);

        //    box.Name = "Example";
        //    //box.HasLine.
        //    int j = 1;

        //    List<RadioButton> listradio = new List<RadioButton>();
        //    for (int i = 1; i <= 3; i++)
        //    {
        //        listradio.Add(excelbook.Worksheets[0].Shapes.AddRadioButton(row, 0, 1, 0, 30, 110));
        //        row++;
        //    }
        //    row++;row++; row++; row++;


        //    Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[4];
        //    shapeobjects[0] = box;
        //    //int i = 1;
        //    foreach (RadioButton item in listradio)
        //    {
        //        shapeobjects[j] = item;
        //        j++;
        //    }
        //    Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects);
        //}
        //excelbook.Save("D:\\New folder\\" + "book1.xls");

        // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! 
    }

@kiranmurkal,

Thanks for the code segment and details.

After an initial test, I am able to reproduce the issue as you mentioned via your sample code. I found that I could not group radio buttons (in group box) row wise for different sets. I even tried different variations but to no avail:
e.g
Sample code:

Workbook excelbook = new Workbook();

        // Worksheet objtempworksheet = null;
        int row = 3;
        for (int ques = 1; ques <= 2; ques++)
        {

            //}
            int column = 1;
            Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(row, 0, column, 0, 21, 150);

            box.Name = "Example";
            //box.HasLine.
            //box.IsHidden = true;
            int j = 1;

            List<Aspose.Cells.Drawing.RadioButton> listradio = new List<Aspose.Cells.Drawing.RadioButton>();
            for (int i = 1; i <= 3; i++)
            {
                listradio.Add(excelbook.Worksheets[0].Shapes.AddRadioButton(row, 0, column, 0, 30, 40));
                column++;
            }
            row++; row++; row++; row++;
            column++; 

            Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[4];
            shapeobjects[0] = box;
            //int i = 1;
            foreach (Aspose.Cells.Drawing.RadioButton item in listradio)
            {
                shapeobjects[j] = item;
                j++;
            }
            Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects);
        }

        excelbook.Worksheets[0].IsGridlinesVisible = false;

        excelbook.Save("e:\\test2\\book1.xls");

I have logged a ticket with an id “CELLSNET-47076” for your issue. We will evaluate your issue thoroughly and check if your code segments needs some tweaks so we may provide you updated code segment or fix the issue (if found).

Once we have an update on it, we will let you know.

Thanks …
i have fixed it please see below code…
static void Main(string[] args)
{
string root = @“D:\New folder”;
System.IO.DirectoryInfo di = new DirectoryInfo(root);
if (Directory.Exists(root))
{
foreach (FileInfo file in di.GetFiles())
{
file.Delete();
}
// Directory.Delete(root);
}

        Workbook excelbook = new Workbook();
        excelbook.Worksheets[0].IsGridlinesVisible = false;
        // Restricting users to edit contents of the worksheet
        excelbook.Worksheets[0].Protection.AllowEditingContent = false;
        // Restricting users to edit objects of the worksheet
        excelbook.Worksheets[0].Protection.AllowEditingObject = false;
        // Restricting users to edit scenarios of the worksheet
        excelbook.Worksheets[0].Protection.AllowEditingScenario = false;
        excelbook.Worksheets[0].Protection.AllowDeletingRow = false;
        excelbook.Worksheets[0].Protection.AllowDeletingColumn = false;
        excelbook.Worksheets[0].Protection.AllowInsertingColumn = false;
        excelbook.Worksheets[0].Protection.AllowInsertingRow = false;
        // Worksheet objtempworksheet = null;
        int row = 1;
        for (int ques = 1; ques <= 2; ques++)
        {

            //}
            int column = 1;
            Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(row, 0, column, 0, 50, 250);

            box.Name = "Example";
            //box.HasLine.
            box.IsHidden = false;
            int j = 1;


            List<Aspose.Cells.Drawing.RadioButton> listradio = new List<Aspose.Cells.Drawing.RadioButton>();
            for (int i = 1; i <= 3; i++)
            {
                listradio.Add(excelbook.Worksheets[0].Shapes.AddRadioButton(row, 0, column, 0, 30, 110));
                column++;
            }
            row++; row++; row++; row++;


            Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[4];
            shapeobjects[0] = box;
            //int i = 1;
            foreach (Aspose.Cells.Drawing.RadioButton item in listradio)
            {
                shapeobjects[j] = item;
                j++;
            }
            Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects);
        }
        excelbook.Save("D:\\New folder\\" + "book1.xls");
        // The code provided will print ‘Hello World’ to the console.
        // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
        //string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        //string root = @"D:\New folder";
        // System.IO.DirectoryInfo di = new DirectoryInfo(root);
        //if (Directory.Exists(root))
        //{
        //    foreach (FileInfo file in di.GetFiles())
        //    {
        //        file.Delete();
        //    }
        //   // Directory.Delete(root);
        //}

        //Workbook excelbook = new Workbook();
        //excelbook.Worksheets[0].IsGridlinesVisible = false;
        //excelbook.Worksheets[0].Protection.AllowDeletingRow = false;
        //excelbook.Worksheets[0].Protection.AllowDeletingColumn = false;
        //excelbook.Worksheets[0].Protection.AllowInsertingColumn = false;
        //excelbook.Worksheets[0].Protection.AllowInsertingRow = false;
        //// Worksheet objtempworksheet = null;
        //int row = 1;
        //for (int ques = 1; ques <= 2; ques++)
        //{

        //    //}

        //        Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(row, 0, 1, 0, 100, 250);

        //    box.Name = "Example";
        //    //box.HasLine.
        //    int j = 1;

        //    List<RadioButton> listradio = new List<RadioButton>();
        //    for (int i = 1; i <= 3; i++)
        //    {
        //        listradio.Add(excelbook.Worksheets[0].Shapes.AddRadioButton(row, 0, 1, 0, 30, 110));
        //        row++;
        //    }
        //    row++;row++; row++; row++;


        //    Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[4];
        //    shapeobjects[0] = box;
        //    //int i = 1;
        //    foreach (RadioButton item in listradio)
        //    {
        //        shapeobjects[j] = item;
        //        j++;
        //    }
        //    Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects);
        //}
        //excelbook.Save("D:\\New folder\\" + "book1.xls");

        // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! 
    }

@kiranmurkal,

Thanks for the code segment.

I evaluated it further and found by extending the height of the container (groupbox) will fix your issue. In short, it is always better to set appropriate height/width of the container control so it could insert the radio buttons precisely and then we can group the sets properly.