开发者

Where do I have to put the code?

I have an application which downloads some data and I want to show that data on a listView. By deafault Mfc shows me some code, a namepace and a class with that listView. There is also a seperate cpp file with a main with this code:

int main(array<System::String ^> ^args)
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 

    // Hauptfenst开发者_开发百科er erstellen und ausführen
    Application::Run(gcnew Form1());

    return 0;
}

I don't know where to put my function in this main which downloads stuff, and how to address and alter this listView

inside the main this doesn't work:

Form1->listView1->Text = "asdasdasdasd"


This is not MFC, this is C++/CLI with Windows Forms. You need to place your code to some Form1 event handler, for example, Load event handler. Double-click Form1 in Design view to create event handler, and place your code there.

Later you may improve the program logic by handling some button events (for example, add Download button and handle its Click event) and using background threads. But on the first step just try Form.Load event.


A quick solution:

Form1 theForm = gcnew Form1();
theForm->listView1->Text = "Text here";
Application::Run(theForm);

But you should implement the same in one of the events for Form (like Load event).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜