Thread: Windows form App: listbox

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    5

    Windows form App: listbox

    I have a windows form application in which I am trying to add a line to the listbox component from another object.

    The object is a socket object that connects, sends msgs.. etc.
    but I want to show the results of some functions of the socket object in the listbox of the windows form.

    If I create an instance of the socket object in the windows form, then how can I add new lines to the listbox?

    Would I have to pass an instance of the windows form and pass it to the socket object?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Can't you just add the result?

    Code:
    int i = sock.Send( ... );
    listBox1.Items.Add("Result of send was " + i.ToString());

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    5
    I do all the socket related stuff in one object. The form has the the socket object and I have no way of passing an instance of the form object to the socket object since the socket object is used in the form object.

    So far I have beein trying to call a function like

    Code:
    void AddLine(String* line)
    {
        listbox1->Items->Add(line);
    }
    but since i have no way of getting an instance of the form object to the socket object, I am stumped.
    Last edited by hslee16; 04-26-2004 at 10:06 PM.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> but since i have no way of getting an instance of the form object to the socket object
    There's always a way....global variables, global functions, etc...

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows Form Application ?
    By messi10 in forum C# Programming
    Replies: 3
    Last Post: 04-13-2009, 08:07 AM
  2. Replies: 2
    Last Post: 12-22-2006, 08:45 PM
  3. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  4. one Windows form property?
    By SuperNewbie in forum C# Programming
    Replies: 1
    Last Post: 07-18-2002, 07:26 AM
  5. Turning a Console APP into Windows.
    By Darkflame in forum C++ Programming
    Replies: 3
    Last Post: 09-14-2001, 03:10 AM