Clear MenuHandler does not clears Row 0

Still in ListBox.

in the Clear MenuItem, the used code does not clears Row 0.

I stepped in the debugger and found that when LoopIdx = 0, the code exits the MenuHandler afterLB.RemoveRow(LoopIdx):

If LB.Selected(LoopIdx) Then LB.RemoveRow(LoopIdx)

and the Change Event is fired.

Of course the loop use:

For LoopIdx = RowCnt DownTo 0

RowCnt is defined earlier:

RowCnt = LB.ListCount - 1

and LB is the name of my ListBox.

BTW: the code clears every other Row # in the ListBox.

Why not use Listbox.DeleteAllrows ?

Good question.
Just because it is used elsewhere (EditSelectAll, then EditDelete who delete al).

This is “EditClear” who clears (delete) the selected Rows.

[quote=202686:@Emile Schwarz]@Eli Ott Why not use Listbox.DeleteAllrows ?
Good question.
Just because it is used elsewhere (EditSelectAll, then EditDelete who delete al).

This is “EditClear” who clears (delete) the selected Rows.[/quote]

You are confusing menus and Listbox method :stuck_out_tongue:

See http://documentation.xojo.com/index.php/ListBox.DeleteAllRows

[quote=202691:@Michel Bujardet]You are confusing menus and Listbox method :stuck_out_tongue:

See http://documentation.xojo.com/index.php/ListBox.DeleteAllRows[/quote]
No, I am not.

I call DeleteAllRows somewhere and here I want to delete the selected Rows, I use RemoveRow.

[quote=202697:@Emile Schwarz]For LoopIdx = RowCnt DownTo 0
RowCnt is defined earlier:

RowCnt = LB.ListCount - 1[/quote]

Does this you posted not delete all rows :

[code]For LoopIdx = RowCnt DownTo 0
RowCnt is defined earlier:

RowCnt = LB.ListCount - 1[/code]

To me, Listbox.Listcount-1 down to zero removes all rows…

But hey, it is your program. I was just trying to assist. Have fun :wink:

[quote=202703:@Michel Bujardet]Does this you posted not delete all rows :

[code]For LoopIdx = RowCnt DownTo 0
RowCnt is defined earlier:

RowCnt = LB.ListCount - 1[/code]

To me, Listbox.Listcount-1 down to zero removes all rows…

But hey, it is your program. I was just trying to assist. Have fun ;)[/quote]
He’s not just calling RemoveRow. He’s checking some other conditional code (probably that the row is selected) for each loopidx.

Indeed. So confuse are the explanations, and without the full code…