How to select entries in ListBox in SingleSelect Mode?

The place for threads about TimoSoft ComboListBoxControls
Post Reply
Rucksacktraeger
Lieutenant
Posts: 23
Joined: 15 Aug 2010, 08:42

How to select entries in ListBox in SingleSelect Mode?

Post by Rucksacktraeger »

I could select an Entry this way:

Code: Select all

LstU.ListItems(3).Selected = True 'Markiert Item 4
but why only in MultiSelect Mode? If I am not in MultiSelect Mode, how can I select Entries? With Select I mean to put the Caret on the selected position AND get the Background blue.

In MultiSelectMode 0 I get an error like this: Method 'Selected' for the Object 'IListBoxItem' failed (translated from german)


Btw: I tried the Unicode Listbox a lot and I played also with this:

Code: Select all

MsgBox LstU.SelectedItem.Index '3
MsgBox LstU.ListItems.Item(3).Index '3
MsgBox LstU.CaretItem.Index '3
MsgBox LstU.CaretItem.Selected 'wahr
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: How to select entries in ListBox in SingleSelect Mode?

Post by TiKu »

Try this:

Code: Select all

Set LstU.SelectedItem = <YourItem>
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Rucksacktraeger
Lieutenant
Posts: 23
Joined: 15 Aug 2010, 08:42

Re: How to select entries in ListBox in SingleSelect Mode?

Post by Rucksacktraeger »

Thanks, that helped me!
This is my result for anyone with the same Problem:

MultiSelect = 1 or 2

Code: Select all

'    Select
    LstU.MultiSelect = msNormal
    LstU.ListItems(3).Selected = True 'Markiert Item 4
    LstU.ListItems(5).Selected = True 'Markiert Item 6

'    Deselect ALL
    LstU.DeselectItems 'funzt nur bei MultiSelect

'    Deselect one entry ???
MultiSelect = 0

Code: Select all

'   Select
    LstU.MultiSelect = msNone
    Set LstU.SelectedItem = LstU.ListItems.Item(3)

'   Deselect
    LstU.AllowItemSelection = Not LstU.AllowItemSelection 'Trick 17 to loose the Selection (the blue background)
    LstU.AllowItemSelection = Not LstU.AllowItemSelection
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: How to select entries in ListBox in SingleSelect Mode?

Post by TiKu »

Rucksacktraeger wrote:

Code: Select all

'    Deselect one entry ???

Code: Select all

LstU.ListItems(5).Selected = False
Rucksacktraeger wrote:

Code: Select all

'   Deselect
    LstU.AllowItemSelection = Not LstU.AllowItemSelection 'Trick 17 to loose the Selection (the blue background)
    LstU.AllowItemSelection = Not LstU.AllowItemSelection

Code: Select all

Set LstU.SelectedItem = Nothing
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Rucksacktraeger
Lieutenant
Posts: 23
Joined: 15 Aug 2010, 08:42

Re: How to select entries in ListBox in SingleSelect Mode?

Post by Rucksacktraeger »

Hi,

this thread is quite old. But I have to change the old project and I ran again into the problem I had a couple of years ago.

I am in SingleEntry Mode and I can select an entry with this:
Set LstU.SelectedItem = <YourItem>

But I could NOT select a specific row (back than and now.)
LstU.ListItems(5).Selected = False
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: How to select entries in ListBox in SingleSelect Mode?

Post by TiKu »

LstU.ListItems(5).Selected = False will work in multi-selection mode only.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Rucksacktraeger
Lieutenant
Posts: 23
Joined: 15 Aug 2010, 08:42

Re: How to select entries in ListBox in SingleSelect Mode?

Post by Rucksacktraeger »

yeah, so is there really no chance to select a specific row by rownumber?
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: How to select entries in ListBox in SingleSelect Mode?

Post by TiKu »

You can do this:
Set LstU.SelectedItem = LstU.ListItems(5)

Doesn't it work?
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Rucksacktraeger
Lieutenant
Posts: 23
Joined: 15 Aug 2010, 08:42

Re: How to select entries in ListBox in SingleSelect Mode?

Post by Rucksacktraeger »

Wow. Thanks!!!
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: How to select entries in ListBox in SingleSelect Mode?

Post by TiKu »

Ah, and to remove the selection, just set SelectedItem to Nothing.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Post Reply