PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Why my ListBox doesn't work??

Reply

Why my ListBox doesn't work??

 
Thread Tools Rate Thread
Old 24-09-2004, 03:33 AM   #1
=?Utf-8?B?cXVlc3Rpb25z?=
Guest
 
Posts: n/a
Default Why my ListBox doesn't work??


I setup 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 on the 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.
  Reply With Quote
Old 24-09-2004, 04:29 PM   #2
Alex Feinman [MVP]
Guest
 
Posts: n/a
Default Re: Why my ListBox doesn't work??

Dear Questions,
A small code snippet goes a long way towards helping others to understand
what is it you are doing wrong

--
Alex Feinman
---
Visit http://www.opennetcf.org
"questions" <questions@discussions.microsoft.com> wrote in message
news:AA18E957-10EE-4943-A9A7-B1E8540BB0D9@microsoft.com...
>I setup 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 on the
> 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.



  Reply With Quote
Old 24-09-2004, 06:09 PM   #3
=?Utf-8?B?cXVlc3Rpb25z?=
Guest
 
Posts: n/a
Default Re: Why my ListBox doesn't work??

////class1.cs
form1.display ( display_message );
////Form1.cs
public void display(string dis_m)
{
MessageBox.Show(dis_m);
listBox.Items.Add("dis_m");
}

/*Message dialog is shown correctly, but the listbox keeps empty, why?*/

"Alex Feinman [MVP]" wrote:

> Dear Questions,
> A small code snippet goes a long way towards helping others to understand
> what is it you are doing wrong
>
> --
> Alex Feinman
> ---
> Visit http://www.opennetcf.org
> "questions" <questions@discussions.microsoft.com> wrote in message
> news:AA18E957-10EE-4943-A9A7-B1E8540BB0D9@microsoft.com...
> >I setup 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 on the
> > 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.

>
>
>

  Reply With Quote
Old 24-09-2004, 06:13 PM   #4
=?Utf-8?B?cXVlc3Rpb25z?=
Guest
 
Posts: n/a
Default Re: Why my ListBox doesn't work??

//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*/

"Alex Feinman [MVP]" wrote:

> Dear Questions,
> A small code snippet goes a long way towards helping others to understand
> what is it you are doing wrong
>
> --
> Alex Feinman
> ---
> Visit http://www.opennetcf.org
> "questions" <questions@discussions.microsoft.com> wrote in message
> news:AA18E957-10EE-4943-A9A7-B1E8540BB0D9@microsoft.com...
> >I setup 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 on the
> > 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.

>
>
>

  Reply With Quote
Old 24-09-2004, 06:15 PM   #5
Alex Feinman [MVP]
Guest
 
Posts: n/a
Default Re: Why my ListBox doesn't work??

Are you sure it's the right listbox? Also, not that it changes anything
significantly, but you have quotes around dis_m in the call to
ListBox.Items.Add

--
Alex Feinman
---
Visit http://www.opennetcf.org
"questions" <questions@discussions.microsoft.com> wrote in message
news:F010AD70-006A-4064-8DED-CC5DB0F9FC6C@microsoft.com...
> ////class1.cs
> form1.display ( display_message );
> ////Form1.cs
> public void display(string dis_m)
> {
> MessageBox.Show(dis_m);
> listBox.Items.Add("dis_m");
> }
>
> /*Message dialog is shown correctly, but the listbox keeps empty, why?*/
>
> "Alex Feinman [MVP]" wrote:
>
>> Dear Questions,
>> A small code snippet goes a long way towards helping others to understand
>> what is it you are doing wrong
>>
>> --
>> Alex Feinman
>> ---
>> Visit http://www.opennetcf.org
>> "questions" <questions@discussions.microsoft.com> wrote in message
>> news:AA18E957-10EE-4943-A9A7-B1E8540BB0D9@microsoft.com...
>> >I setup 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 on the
>> > 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.

>>
>>
>>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off