Neutering disclosure widgets on Listbox

I want to disable the discourse triangle +/- widget for end users, and only have expandability done programmatically.

Doing research on this, I came across the documentation on PaintDisclosureWidget which states I should be able to do this. From the doc:

“Setting width or height to zero will completely hide the triangle and no hit testing will be done.”

However, while I can hide the widget using this method, a user can still click in that area and make the row expand.

Here’s what I’ve tried:

g.foreColor=RGB(255,255,255)
if me.RowExpandableAt(row) then
  g.FillRectangle (0,0,0,0)
end if
return True

and

g.foreColor=RGB(255,255,255)
if me.RowExpandableAt(row) then
  g.drawstring "",0,0
end if
return true

In fact, just having “Return True” with no other code accomplished the exact same thing!

Any ideas?

Thanks!

In the RowExpanded event you can just collapse the row unless a flag that you set is true.

if not programaticallyExpanding then
  me.RowExpandedAt(row) = false
  return
end

If you look at the signature for that method, there are two byref parameters which allow you to define the hit area. You should be able to set one or both to zero:

g.foreColor=RGB(255,255,255)
if me.RowExpandableAt(row) then
  g.drawstring "",0,0
end if
Height = 0 // THIS
return true

Jared, I get this error with your method:

MAIN.SCRIPT_LISTBOX.RowExpanded, line 1
This item does not exist
if not programaticallyExpanding then

Grog, that seems to be working.

In fact, I don’t even need the condition or the Return True. The works by itself.

g.foreColor=RGB(255,255,255)
g.drawstring "",0,0
Height = 0

You would need to create the programaticallyExpanding property and set it to true when you are programmatically expanding the row and then back to false.