Problem about ListBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I create a Form and call another class (e.g. class1.cs). (class1.cs) contains
a command to call back the Form to display a string variable in a listbox.
However, it doesn't works. The listbox gets no response.
Command:
listBox.Items.Add( str );
However, it works when i type "MessageBox.Show( str);". A correct string
displays in the popup message box.
Can anyone help me?
 
Hi,

Could you be more precise with:
"(class1.cs) contains a command to call back the Form to display a
string variable in a listbox"

Do you keep form reference in that class or do you raise any event?

Regards

Marcin
 
You will probably need to create a public function in the form that takes
the str as a parameter.
Then you can call the function from (class1.cs)
 
//class1.cs
display ( display_message );
//Form1.cs
public void display(string dis_m)
{
MessageBox.Show(dis_m);
listBox.Items.Add(dis_m);
}

/*Message Dialog display correctly, but the listbox is still empty. Please
help me*/
 
Back
Top