473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

listbox used to display program status

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.frmMa in.listBox1.Items.Count,xM
SG);
if(PagingDN.frmMain.listBox1.Items.Count>100){
PagingDN.frmMain.listBox1.Clear();
}
}
}
Nov 16 '05 #1
2 1751
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

"xzzy" wrote:
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.frmMa in.listBox1.Items.Count,xM
SG);
if(PagingDN.frmMain.listBox1.Items.Count>100){
PagingDN.frmMain.listBox1.Clear();
}
}
}

Nov 16 '05 #2
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
"Shailen Sukul" <Sh**********@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
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

"xzzy" wrote:
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.frmMa in.listBox1.Items.Count,xM SG);
if(PagingDN.frmMain.listBox1.Items.Count>100){
PagingDN.frmMain.listBox1.Clear();
}
}
}

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wishing I was skiing mom | last post by:
Newbie to VB .NET. My solution contains an item maintenance screen, one of the fields on the screen is an item status, this field is defined as a listbox. The listbox item property contains a...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
2
by: Wishing I was skiing mom | last post by:
Newbie to VB .NET. My solution contains an item maintenance screen, one of the fields on the screen is an item status, this field is defined as a listbox. The listbox item property contains a...
7
by: mikeh3275 | last post by:
I'm creating a .net program that uploads images to the FTP server. A blank listbox is populated dynamically on the client side from the value of the html input file widget. There is also a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.