08-20-2012, 04:52 PM
Let me understand you want to create a new form(window) and add items to the list.
Here is a simple example how you can controll another class, from another class.
//the form class
public partial class Form1 : Form
{
private MyClass mc = new MyClass();
public Form1()
{
InitializeComponent();
mc.setup(new object[] { this });
}
private void button1_Click(object sender, EventArgs e)
{
mc.Add();
}
//interface method from the window form
public void addTextLine(string msg)
{
listBox1.Items.Add(msg);
}
}
//my class
class MyClass
{
//an instance to the form class
public Form1 windowsForm;
//get the data from yje form class
public void setup(object[] args)
{
if (args != null)
{
windowsForm = (Form1)args[0];
}
}
//methods to access the form class
public void Add()
{
windowsForm.addTextLine("stuff");
}
}
no, i made a Class "MySql1" for my Commands etc..
But now i wanna fill the listBox from Form1 .. and it wont work ..
i try now wizas recommend

