Write to a listBox in another form [duplicate]

0

Good stack.

I am developing a small application for automatic backup of MySQL and SQL Server databases. The application is to be done in Windows Forms + C #.

I thought I would implement something similar to a "console", actually being a listBox that will save the logs. My idea was to be able to save the logs inside that listBox. For example:

14:22:34 - Vou começar a backup a base de dados: user_control
14:23:10 - Terminei o backup de: user_control C:/backups

Now about the question. How can I submit class content to this listBox? I have multiple classes and multiple forms, but I always send to a single location.

I tried to create a public function in the same form of the listBox and send arguments there. The function would pick it up and put it in the listBox. But I can not call the function without creating a new instance.

To such a function. It is in Form1.cs

public void addLog(string content) {
        ConsoleLog.Items.Add(content);
    }

An example of what I've been trying to do. You are in frmAddition.cs

addLog("Olá mundo");

I do not know if I have explained myself clearly, I am willing to share more information.

    
asked by anonymous 18.01.2018 / 10:46

0 answers