10-07-2019 01:40 PM
Hello,
I have a ListBox with a couple of listitems on Dialog Box.
I have a script to select listitem for doing somthing. Could you please help how to deselect that selected listitem with script?
Regards,
Gman
Solved! Go to Solution.
10-07-2019 03:03 PM
In this example SUD I have attached, I fill a listbox with some numbers on startup. As soon as i make a selection, it deselects. Basically, do:
ListBox.Selection = -1
10-08-2019 07:22 AM
Hi gsklyr,
Thank you for your advice.
It's my fault not to explain my question clearly.
The following is what I want to do:
1. Click one listitem to trigger a "ListBox1_EventChange" for doing something.
2. Deselect the selected listitem.
3. Repeat step1.2 (clicking same listitem).
Now the issue is I only can trigger "ListBox1_EventChange" once by clicking the same listitem before I click other listitems, even I reset Listbox1.selection to -1 as your suggestion.
By the way I cannot open your example.
Thanks,
Gman
10-08-2019 09:13 AM - edited 10-08-2019 09:26 AM
'------------------------------------------------------------------------------- '-- SUD script file '-- Created on 10/08/2019 09:04:29 '-- Author: '-- Comment: '------------------------------------------------------------------------------- Option Explicit 'Forces the explicit declaration of all the variables in a script. 'Note: In this area area you can program auxiliary variables and functions that you can use in the entire dialog box. Sub ListBox1_EventInitialize(ByRef This) 'Created Event Handler Call ListBox1.Items.RemoveAll() Call ListBox1.Items.Add(" - 1 - ", 0) Call ListBox1.Items.Add(" - 2 - ", 1) Call ListBox1.Items.Add(" - 3 - ", 2) Call ListBox1.Items.Add(" - 4 - ", 3) End Sub Sub Button1_EventClick(ByRef This) 'Created Event Handler ListBox1.Value = -1 ListBox1.Selection = -1 End Sub Sub ListBox1_EventChange(ByRef This) 'Created Event Handler If ListBox1.Selection = -1 Then Call MsgBox("De-Select Event") Else Call MsgBox("Regular Event") End If End Sub
Instead of the button, you can have th last line of your event change be listbox1.selection = -1 to clear
Sorry the key is to clear the value as well... listbox.value = -1 (read your post more carefully)
10-09-2019 07:08 AM
Hi gsklyr,
I'm really appreciated your response. It really help me.
Here is my lesson from practice:
These two commands,ListBox1.Value = -1
ListBox1.Selection = -1, cannot be put inside "ListBox1_EventChange(ByRef This)".