lundi 25 mai 2015

C++ check which checkbox is checked in panel

can someone please help me with the following problem. When I push the button I need to check which checkbox are checked in the panel. By default all checkboxes are checked. The idea is to have a vector that I store order number of the checkbox that is checked. Code for dinamic input checkbox in panel is:

            for each (FileInfo^ f in info->GetFiles())
            {
                for (int i = 0; i < validExtensions->Length; i++)
                {
                    if (f->Extension->ToString()->ToLower() == validExtensions[i]->ToLower())
                    {
                        PictureBox^ pb = gcnew PictureBox();
                        CheckBox^ cb = gcnew CheckBox();

                        pb->Name = "ImagePB" + countPB;
                        cb->Name = "CheckBox" + countCB;

                        pb->Cursor = Cursors::Hand;

                        pb->Parent = panel1;                            
                        pb->Size = System::Drawing::Size(130, 130);
                        cb->Parent = panel1;

                        pb->SizeMode = PictureBoxSizeMode::StretchImage;

                        pb->Location = Point(positionX + 10, positionY);
                        cb->Location = Point(positionX + 70, positionY + 130);

                        pb->Image = Image::FromFile(f->FullName);

                        pb->Image->Tag = f->FullName;

                        pb->Click += gcnew System::EventHandler(this, &Forma1::pb_Click);

                        positionX += 141;
                        if (positionX >= 770)
                        {
                            positionY += 154;
                            positionX = 0;
                        }

                        countPB += 1;
                        countCB += 1;

                        cb->Checked = true;
                    }
                }
            }

Thanks!!




Aucun commentaire:

Enregistrer un commentaire