Announcement

Collapse
No announcement yet.

Right Click on Listbox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Right Click on Listbox

    Hello i am trying to create a table Menu on listbox to delete each line..
    i am try but no success..

    what i have now is select line on listbox and press delete on keyboard to delete the line.. but i want to have a right click showing the menu to delete..

    anyone could help? Thanks in advance...

  • #2
    Not entirely clear on exactly what you're asking, but if you mean how to delete selected item in Listbox, do like this:


    Code:
    index = ListBox.GetSelected("ListBox1");
    
    if (index ~= nil) then
     ListBox.DeleteItem("ListBox1", index[1]);
    end

    Comment


    • #3
      ...And if your Listbox is multi-select enabled (ie. if you wish to select and delete multiple items from it), then:

      Code:
      index = ListBox.GetSelected("ListBox1");
      
      if (index ~= nil) then
          for k, v in pairs (index) do
            ListBox.DeleteItem("ListBox1", index[1]);
          end
      end

      Comment


      • #4
        Hello bio thanks for your response.. i want to create a right click on my listbox that there is a menu with delete..
        Example on listbox there is 3 item if i want to delete the 2nd one i need to right click and select delete..

        Comment


        • #5
          Okay, I get you. Have a look at the attached "right click menu" APZ. It's not exactly what you're after - but should steer you in the right direction. With some mods to the menu code, you should be able to make some progress.
          Attached Files

          Comment


          • #6
            Thank you so much i never come up with this idea.. Thank you Bio you really help a knob like me...
            what i have now is i click on listbox and press delete on keyboard to delete selected listbox...

            Comment


            • #7
              No problem. Had some time to kill this morning - so modded the above apz to what you're seeking. Have a look at the newly attached example - I think this is more in line with what you're after, yeah?
              Attached Files

              Comment


              • #8
                Thanks bio i already got it with your first share.. thanks so much..

                Comment


                • #9
                  Cool. Beer and skittles for everyone, then?
                  Now I can get back to watching my movie - 'The Forgiven'. (Eric Bana is so-oo bad-ass in this film!).

                  Comment


                  • #10
                    wow.. dont see that movie yet..

                    Comment


                    • #11
                      Hello bio.. can i get some help again with this code?
                      i have a text file that will load to the listbox.


                      when i delete specific entry on listbox how to delete it also on the text file?


                      Example on Textfile i have:

                      1. America
                      2. Japan
                      3. Korea

                      On my lisbox i want to delete the Japan also it will delete on my textfile..


                      Thanks..


                      Comment


                      • #12
                        Yep, here's one way to go about it - see attached. Just a matter of reading your textfile data into table and referencing from there.
                        .
                        Not sure if this example is completely bug-free. Too tired to check properly right now and starting to hallucinate coding elves, again. (Should about do the trick, though).
                        Attached Files

                        Comment


                        • #13
                          Thanks Bio it works but the problem if the lisbox is on Sort it will delete incorrect line of the textbox.

                          Comment


                          • #14
                            i mean it will delete incorrect line from the textfile.. but it sort is not check it works fine..

                            Comment


                            • #15
                              That's a one-line fix. Use the Table.Sort() function. Place this immediately after Line-5 on the Load Listbox button, so that the data gets sorted right after it gets read to table from textfile:
                              Code:
                              Table.Sort(tMyText, nil);
                              That way the data is sorted regardless of whether your Listbox has the sort-function checked. Fix is attached.

                              The alternative would be to do it at Line-18 on the Delete from Listbox button, so that the tMyText variable containing the table is sorted prior to overwriting the textfile.
                              Attached Files

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎