ControlDeleteItem throws an error.
Issue #74
closed
Test code:
MyGui := Gui()
; ┌─────────────┐
; │ Combo Box │
; └─────────────┘
ThirdText4 := MyGui.Add("Text", "x10 cBlue s10", "ComboBox")
MyCB := MyGui.Add("ComboBox", "x10 y+10 r10 -Limit", ["Orange","Purple","Fuchsia","Lime","Aqua"])
CB_Button := MyGui.Add("Button", "s8 x10 y+10", "Show CB Selection")
CB_AddBtn := MyGui.Add("Button", "s8 x140 yp", "Add 'Yellow' to CB")
CB_Button.OnEvent("Click", "CB_ButtonClicked")
CB_AddBtn.OnEvent("Click", "AddYellow")
CB_DeleteBtn := MyGui.Add("Button", "s8 h25 w80 x10 y+20", "Del Yellow")
CB_DeleteBtn.OnEvent("Click", "DeleteYellow")
MyGui.Show()
; ┌─────────────────────┐
; │ ComboBox Callback │
; └─────────────────────┘
AddYellow() {
ControlAddItem("Yellow", MyCB)
}
CB_ButtonClicked() {
MsgBox(MyCB.Text, "CB Selection")
}
DeleteYellow() {
ControlDeleteItem("Yellow", MyCB)
}
Error:
---> System.FormatException: Input string was not in a correct format.
Comments (4)
-
repo owner -
reporter That makes me feel bad. I already had a test for deleting an item from a ListBox right above it in guitest.ahk, and didn’t duplicate it.
Closing.
-
reporter - changed status to invalid
Not a bug.
-
reporter - changed status to closed
Closing.
- Log in to comment
You are passing “Yellow” to the function. The documentation here:
https://lexikos.github.io/v2/docs/commands/ControlDeleteItem.htm
says the first parameter is a 1-based integer index of the item you want to delete.
So the parsing error is exactly what we’d expect.