473,378 Members | 1,619 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,378 software developers and data experts.

Problem about ListBox

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?

Nov 16 '05 #1
4 1737
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
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?

Nov 16 '05 #2
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)

"questions" <qu*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
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?

Nov 16 '05 #3
I have already set it to be public. But it still doesn't work.

"Dante" wrote:
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)

"questions" <qu*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
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?


Nov 16 '05 #4

//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*/
"questions" wrote:
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?

Nov 16 '05 #5

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

Similar topics

2
by: Matt Sawyer | last post by:
Hi, I'm attempting to do a drag and drop operation from one listbox to another. I have my listboxes setup with SelectionMode = MultiExtended so that I can use the shift key, cntrl key, etc. to...
1
by: Josema | last post by:
Hi to all, I have a class (persons) that derives from collection base: and another class (person) with this properties: -ID -Name When i have complete filled the object Persons with all...
3
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
0
by: Ken Varn | last post by:
I have a strange problem with a databound listbox. It may be because of how I use it, but I am stumped by this behavior. Here is the scenario: I have a multiselect databound listbox that...
4
by: amber | last post by:
Hello I'm not sure if I should give up trying to find an answer here...or just keep posting my problem.. I'm having problems with a listbox.. I have a listbox that is populated when a user...
2
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: -------------------------------...
5
by: Alien2_51 | last post by:
I have a problem with a ListBox control that is on a TabControl, it seems to be forgetting which items are selected in the list when I tab off the current tab, here's my winform code... I even...
1
by: Mart?n Llanos via .NET 247 | last post by:
I've this problem, in my aspx i put a ListBox, when i add lines to this ListBox and and click de button "Guardar", a java script function is called. In that java script I have this code: var...
1
by: faheem ramzan via .NET 247 | last post by:
I have a problem using listbox. I used to put items in listbox dynamically and maintained size automatically in listbox sothat there is no scroll bar in the listbox. I have a problem when the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.