Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2008
    Posts
    165

    PLEASE help me to understand this problem with Combobox vs Listbox!!

    Right, I am appealing for help with helping me understand why the code I use for combobox will not work with listbox...

    Example of what I mean is:
    Code:
    -- Adds 7 items to the combo box as shown below:-
    ComboBox.AddItem("ComboBox1", "Day 1", "Monday");
    ComboBox.AddItem("ComboBox1", "Day 2", "Tuesday");
    ComboBox.AddItem("ComboBox1", "Day 3", "Wednesday");
    ComboBox.AddItem("ComboBox1", "Day 4", "Thursday");
    ComboBox.AddItem("ComboBox1", "Day 5", "Friday");
    ComboBox.AddItem("ComboBox1", "Day 6", "Saturday");
    ComboBox.AddItem("ComboBox1", "Day 7", "Sunday");
    Button 1:
    Code:
    cb_Selected = ComboBox.GetSelected("ComboBox1");
    cb_ItemText = ComboBox.GetItemText("ComboBox1", cb_Selected);
    cb_ItemData = ComboBox.GetItemData("ComboBox1", cb_Selected);
    
    Dialog.Message(cb_ItemText, cb_ItemData, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    BUT....

    Code:
    -- Adds 7 items to the list box as shown below:-
    ListBox.AddItem("ListBox1", "Day 1", "Monday");
    ListBox.AddItem("ListBox1", "Day 2", "Tuesday");
    ListBox.AddItem("ListBox1", "Day 3", "Wednesday");
    ListBox.AddItem("ListBox1", "Day 4", "Thursday");
    ListBox.AddItem("ListBox1", "Day 5", "Friday");
    ListBox.AddItem("ListBox1", "Day 6", "Saturday");
    ListBox.AddItem("ListBox1", "Day 7", "Sunday");
    Button 2:
    Code:
    lb_Selected = ListBox.GetSelected("ListBox1");
    lb_ItemText = ListBox.GetItemText("ListBox1", lb_Selected);
    lb_ItemData = ListBox.GetItemData("ListBox1", lb_Selected);
    
    Dialog.Message(lb_ItemText, lb_ItemData, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    DOES NOT work...

    Also, attached is the sample project I am talking about.

    So WHY wont the listbox work just like the combobox does with the same code? PLEASE help me to understand this!!

  2. #2
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Maybe you should read the manual on ListBox instead of simply renaming
    the actions... ListBox.GetSelected returns a table instead of a number...

    Try:
    Code:
    lb_Selected = ListBox.GetSelected("ListBox1");
    if(lb_Selected)and(lb_Selected[1])then
        lb_ItemText = ListBox.GetItemText("ListBox1", lb_Selected[1]);
        lb_ItemData = ListBox.GetItemData("ListBox1", lb_Selected[1]);
        Dialog.Message(lb_ItemText, lb_ItemData, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end

    And before you ask, ListBox.GetSelected returns a table, because with multiselection enabled, multiple items can be selected. All these selected item's indexes will be inserted in that table.
    Last edited by Imagine Programming; 03-07-2010 at 04:40 AM.
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  3. #3
    Join Date
    Jun 2008
    Posts
    165
    Quote Originally Posted by Imagine Programming View Post
    Maybe you should read the manual on ListBox instead of simply renaming
    the actions... ListBox.GetSelected returns a table instead of a number...

    Try:
    Code:
    lb_Selected = ListBox.GetSelected("ListBox1");
    if(lb_Selected)and(lb_Selected[1])then
        lb_ItemText = ListBox.GetItemText("ListBox1", lb_Selected[1]);
        lb_ItemData = ListBox.GetItemData("ListBox1", lb_Selected[1]);
        Dialog.Message(lb_ItemText, lb_ItemData, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    Thanks for the explanation!
    I did read the help part, but what I have found is that help help and examples are only a tiny bit of help, as with what I found about ListBox.GetSelected is:
    Example 1
    List_Select = ListBox.GetSelected("File List");

    Gets the indexes of all of the currently selected items in the "File List" listbox object and stores the results in a table called "List_Select."

    Example 2
    -- Get the indexes of the items currently selected in the listbox.
    selected_items = ListBox.GetSelected("ListBox1");

    -- If there were items selected in the listbox, display a dialog with their indexes.
    -- If no items were selected, display a notification message.
    if (selected_items ~= nil) then
    output = "";
    for index, item in selected_items do
    output = output..item.."\r\n";
    end
    Dialog.Message("Selected Items", "The indexes of the selected items are:\r\n\r\n"..output);
    else
    Dialog.Message("Selected Items", "There are no selected items in the listbox.");
    end

    Gets the indexes of all of the currently selected items in the "ListBox1" listbox object and stores the results in a table called "selected_items." If any items were selected, their indexes are displayed in a dialog message. If no items were selected, a dialog message is shown notifying the user.
    Which doesn't even come close to the example that you posted for me, please don't get me wrong, I am not having a go or being disrespectful, I AM gratefull for your explanation, which is what I wanted to know, I just wish the examples would show ALL the possible options and usages.

  4. #4
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by SteevieNiteHeat View Post
    Thanks for the explanation!
    I did read the help part, but what I have found is that help help and examples are only a tiny bit of help, as with what I found about ListBox.GetSelected is:


    Which doesn't even come close to the example that you posted for me, please don't get me wrong, I am not having a go or being disrespectful, I AM gratefull for your explanation, which is what I wanted to know, I just wish the examples would show ALL the possible options and usages.
    If you read the complete AMS documentation, you'll find everything you need to know to do what I just did If you find out an action returns a table, start reading the helpfile about tables, and you'll see what you can do
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  5. #5
    Join Date
    Jun 2008
    Posts
    165
    Quote Originally Posted by Imagine Programming View Post
    If you read the complete AMS documentation, you'll find everything you need to know to do what I just did If you find out an action returns a table, start reading the helpfile about tables, and you'll see what you can do
    cheers, I will look out for that in future
    Might even help me complete all the projects i got stuck on and just left

  6. #6
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by SteevieNiteHeat View Post
    cheers, I will look out for that in future
    Might even help me complete all the projects i got stuck on and just left
    You should never quit because of limitations, always seek for answers,
    plow through the helpfile, documentation, forums, searchfunction of the forum is awesome! google stuff, MSDN stuff, use winapi calls and learn!
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts