0

I am trying to return a number of created labels in a vector to a form and then add them to the form. But i get a lot of errors, my guess is that i'm using the ref class (that i use the pointer ^) wrong. The code (a little modified) work at first in the event handlare of a button , but then when i moved it ( tryed to modified it to fit) to the class method it caused lots of errors such as "error C3699: '*' : cannot use this indirection on type 'System::Windows::Forms::Label'" , there is about 80 of thesse error. What i'm i doing wrong?

code: header file:

ref class Bingo 
{
public:
     Bingo();
    ~Bingo();
    //void HighscoreLista();
    //void SkickaText();
    vector<Label> StartaSpelet();
    vector<int> bricka();
    //void AvslutaSpelet();
    //void VisaAndraSpelet();
private:
    vector<int> *pV;
    vector<Label> *pL;
    Label ^myText;
    string *NamnPaSpelet;
};

cpp file:

Bingo::Bingo()
{
    NamnPaSpelet = new string("Bingo");
    pV = new vector<int>;
    pL = new vector<Label>;
    myText = gcnew Label;
    srand(time(NULL));
}

Bingo::~Bingo()
{
    delete NamnPaSpelet;
    delete pV;
}


vector<Label> Bingo::StartaSpelet()
{
    Point punkt(25,60);
    //First label to show the next pulled number

    myText->Text = "click on \"next number\" to start";
    myText->Location = Point(20,20);
    myText->Name="lblDragetNummer";
    myText->AutoSize=true;
    (*pL).push_back(myText);

    //creates the rest of the labels (25)
    for(int i =1; i<=25; i++)
    {

        if (i>0 && i<=5)
            punkt = Point(25+(30*i),60);
        if(i>5 && i <= 10)
            punkt = Point(25+(30*(i-5)),90);
        if(i>10 && i<=15)
            punkt = Point(25+(30*(i-10)),120);
        if(i>15 && i <=20)
            punkt = Point(25+(30*(i-15)),150);
        if(i>20 && i <=25)
            punkt = Point(25+(30*(i-20)),180);

        myText->Text = "Test";
        myText->Location = punkt;
        myText->AutoSize=true;
        (*pL).push_back(myText);
    }

    return *pL;
}

1 Answers1

0

Try defining your pointer-to-vector as a pointer-to-vector of Label refs:

vector<Label^> *pL;
Max Reeder
  • 159
  • 2
  • 6