Disable the selection of a certain ListView row?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
william_ahk
Posts: 486
Joined: 03 Dec 2018, 20:02

Disable the selection of a certain ListView row?

Post by william_ahk » 02 Dec 2021, 19:50

Is it possible to disable one row in a ListView, rendering it unselectable? For example its Checkbox or the entire row will be disabled or hidden.
Similar post found in here. But I couldn't get the code working though.

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Disable the selection of a certain ListView row?

Post by mikeyww » 02 Dec 2021, 21:00

This is my simplistic approach.

Code: Select all

Gui, Font, s10
Gui, Add, ListView, r20 w700 AltSubmit gCheck, A|B|C
LV_Add("", 1, 2, 3), LV_Add("", 4, 5, 6), LV_Add("", 7, 8, 9)
Gui, Show,, Test
Return

Check:
LV_Modify(1, "-Focus -Select")
If !LV_GetNext(0)
 LV_Modify(2, "Select")
If !LV_GetNext(0, "F")
 LV_Modify(2, "Focus")
Return

william_ahk
Posts: 486
Joined: 03 Dec 2018, 20:02

Re: Disable the selection of a certain ListView row?

Post by william_ahk » 03 Dec 2021, 06:23

@mikeyww Thanks! This is quite usable for my needs. If I create the ListView with the Checked option, is there a way to grey out or hide the checkbox on that row as well?

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Disable the selection of a certain ListView row?

Post by mikeyww » 03 Dec 2021, 06:52

You could use the same approach where if that box is selected, you deselect it. You may need to search the forum to find a more literal technique to disabling a single row. It's also possible that this script alone will work with checkboxes; you can test that.

william_ahk
Posts: 486
Joined: 03 Dec 2018, 20:02

Re: Disable the selection of a certain ListView row?

Post by william_ahk » 03 Dec 2021, 06:57

@mikeyww Yes it works for rows with checkboxes as well. I just need a way to show it visually that the row is unselectable. This post here seemed to be implementing this, but I can't get it working and can't understand it :lolno:

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Disable the selection of a certain ListView row?

Post by mikeyww » 03 Dec 2021, 07:06

Sorry I have not tried to do that. Other ideas: show an icon on that row; overlay another control (e.g., a text replica) or transparent image that prevents the click.

Post Reply

Return to “Ask for Help (v1)”