Hello,
I have a WinForm called frmMain and a class called IRCEngine, they are in the same namespace. In my class i want to add items in a listview which is in the frmMain. but it doesn't work : its doesn't add but if u put a messagebox IN the same method, the msg box is shown but the listview are not added...
frmMain.cs (winform)
IRCEngine.cs (my class)
ListView (lstUsers) & oConsole (richtextbox) are "Public" (modifiers).
So why its doesn't append or add items in the form from the class? and why its doesn't add items BUT SHOWS MY MESSAGEBOX which is in AddUserInList() ?
Thx a lot
I have a WinForm called frmMain and a class called IRCEngine, they are in the same namespace. In my class i want to add items in a listview which is in the frmMain. but it doesn't work : its doesn't add but if u put a messagebox IN the same method, the msg box is shown but the listview are not added...
frmMain.cs (winform)
Code:
public void AddUserInList(ListViewItem user)
{
MessageBox.Show("MainForm marche : " + user.Text );
this.oConsole.Text = user.Text;
this.Console(user.Text);
this.lstUsers.Items.AddRange( new ListViewItem[] { user } );
}
// other method i use in my class IRCEngine.
public void Console(string text)
{
this.oConsole.AppendText("\n" + text);
}
IRCEngine.cs (my class)
Code:
frmMain MainForm = new frmMain();
public void Connect()
{
this.MainForm.Console("-> Connecting...");
try
{
...
ListViewItem item; // <==========================
while (true)
{
while ((inputLine = reader.ReadLine()) != null)
{
if (...)
{
...
}
else if (...)
{
...
foreach (string user in split)
{
if (user.Length <= 5) { ... }
else
{
item = new ListViewItem(new string[] { user, user.Substring(user.IndexOf('|') + 4)}, -1);
MainForm.AddUserInList(item); // <==========================
}
item = null;
}
Thread.Sleep(1000);
}
else
{
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
So why its doesn't append or add items in the form from the class? and why its doesn't add items BUT SHOWS MY MESSAGEBOX which is in AddUserInList() ?
Thx a lot