0

I have a simple windows form, and a label, from another class I have a loop and I want that every cycle loop the Text propriety of label in form class change, but I can't access it, I tried to make it public but nothing to do.

So how can I change label text from another class?

4

1 に答える 1

2

ラベルを form2 コンストラクターのパラメーターとして渡し、必要なことを行います。

このようなもの:

#include"form2.h"
class form1{

private: Label^ form1Labl;

private: System::Void button1_Click{

form2^ form2Obj= gcnew form2(form1Labl);

form2Obj->Show();

}

};

そしてform2クラスで:

class form2{
private: Label^ lableObj;

form2(Label^ l){ 
lableObj=l;
}

// rest of your code to change lableObj->Text propriety.

};
于 2013-09-12T18:20:30.500 に答える