listbox used to display program status

X

xzzy

I have an app that uses a listbox to display program status messages, and a
public function to be used by the solution to update the listbox.

I do not know how to make the listbox public so it can be updated by that
function.


public class frmMain : System.Windows.Forms.Form{
public System.Windows.Forms.ListBox listBox1;


I would like to access the listbox to do something like this ( this code
does not work ):
public class ListboxOne{
public void AddMsg(string xMSG) {

PagingDN.frmMain.listBox1.items.add(PagingDN.frmMain.listBox1.Items.Count,xM
SG);
if(PagingDN.frmMain.listBox1.Items.Count>100){
PagingDN.frmMain.listBox1.Clear();
}
}
}
 
G

Guest

you could try passing a reference to the listbox as shown below:

public class ListboxOne{
public void AddMsg(System.Windows.Forms.ListBox listBox1,
string xMSG)
{

listBox1.items.add(listBox1.Items.Count,xM
SG);
if(listBox1.Items.Count>100){
listBox1.Clear();
}
}
}

hope it helps :)
Shane Sukul
 
X

xzzy

System.Windows.Forms.ListBox listBox1

of

public class ListboxOne{
public void AddMsg(System.Windows.Forms.ListBox listBox1, string
xMSG) {

defines a listBox, but doesn't reference namespace.frmMain.listBox1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top