Results 1 to 7 of 7

Thread: DELPHI - Moving Listbox Items?

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    DELPHI - Moving Listbox Items?

    A few weeks back, i started making a project on my own, easily discovered how to move a list item up and down the list:

    Code:
    lstMain.Items.Move(lstMain.ItemIndex,lstMain.ItemIndex -1);
    My question comes here, which i feel ridicolous for asking

    1) When you move the item, how do you keep it selected? If i press a up button for example, i always have to click the item, then the button, when really i should'nt

    2) How do you stop the first, and last item in the list from been moved?

    CHEERS

  2. #2

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: DELPHI - Moving Listbox Items?


  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: DELPHI - Moving Listbox Items?

    I am not sure what you mean.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: DELPHI - Moving Listbox Items?

    Imagine, a listbox, a command button for up, and one for down. There are the following items in the list:

    1
    2
    3
    4
    5
    6
    7
    8
    9

    If i highlight 9 (the blue bar highlights the 9) and press the up button, the 9 will swap places with 8 right. Thats hunky dorky, but when i press that button, the listbox loses focus of the 9, meaning the blue bar is no longer over the 9 (so the user would have to re-click the item again)

    Is that better?

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: DELPHI - Moving Listbox Items?

    You would do as you would do in VB:
    Code:
    lstMain.SetFocus;
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: DELPHI - Moving Listbox Items?

    If that works, then i must be such a idiot

    EDIT: I sent you a PM

  7. #7
    New Member Santa Clause's Avatar
    Join Date
    Dec 2003
    Location
    North Pole. Lapland when I visit my Wife.
    Posts
    10

    Re: DELPHI - Moving Listbox Items?

    Why don't you use a special key to move items up and down. In some list boxes, you can move items by holding down the control key and pressing the up and down arrows.

    P.s: Merry Christmas
    I am the real Santa Clause

Posting Permissions

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



Click Here to Expand Forum to Full Width