delete selected row using check box in LB

for i as integer=listbox1.listcount-1 downto 0 if listbox1.selected(i) then listbox1.removeRow(i) end if next

I want to select row in listbox by check (checkbox) to be removed.
how to use check box insteed of click (selected())

Have you read the first paragraph there: Listbox ?

Then, make a search for CheckBox and read all entries.

I use cmd-Shift-Click (Ctrl+Shift+Click) to select more than one Row and cmd-Delete (Ctrl+Del) to delete the selected Row(s).
But this is just me.

[quote=340927:@Emile Schwarz]Have you read the first paragraph there: Listbox ?

Then, make a search for CheckBox and read all entries.

I use cmd-Shift-Click (Ctrl+Shift+Click) to select more than one Row and cmd-Delete (Ctrl+Del) to delete the selected Row(s).
But this is just me.[/quote]

Thank you Emile.

Hello Emile,
I do not found anything about LB CheckBox in .
The following code written by you to delete any row in listbox can be modified to insert a check box in each line (to confirm the deleted row).
Dim ListCnt As Integer // Number of Rows in LB
Dim LoopIdx As Integer // Loop Indice
Dim DelCnt As Integer // Number of Deleted Rows
Dim SelCnt As Integer // Number of Selected Rows
Dim isChanged as boolean

// Get the number of Selected Rows
SelCnt = ListLOP.SelCount

// Exit if no Row is Selected
If SelCnt < 1 Then Exit // This can be tested earlier

// Flag a change occured (Changes have to be saved)
If SelCnt > 0 Then
isChanged = True
End If

// Get the number of Rows in LB
ListCnt = ListLop.ListCount

// Loop thru the Rows from the last to the first and delete any selected row
For LoopIdx = ListCnt DownTo 0
// Delete the row if it is Selected
If ListLOP.CellState(loopdlx,0)=Checkbox.CheckedStates.Checked Then //instead of “If LB.Selected(LoopIdx)”
// Delete the selected Row
ListLOP.RemoveRow LoopIdx

// Inc the number of Selected Rows
DelCnt = DelCnt + 1

End If

// Check if I Deleted all Selected Rows…
If DelCnt = SelCnt Then Exit // No more Rows to Delete ? Exit !

// To avoid 1, Infinite Loop
If UserCancelled Then Exit
Next
dim plot as Graphics
//CnvPlot.Refresh[code]

[/code]

The checkbox is added to the first column of rows but no response when Pusbutton (delete) is pressed.

First paragraph:

The scrollable ListBox control, used to display one or more columns of information. You can add a checkbox and/or a picture to a row and make a cell or column editable.

[code]Class Constants
CellType

The following class constants can be used to specify the values of the CellType and ColumnType properties.
[Some Constants removed]
TypeCheckBox A check box is added to the cell.[/code]

[code] CellState

The CellState method enables you to get or set the value of a tri-state Checkbox cell. Any cell of type TypeCheckbox box can store one of three values: Checked, Unchecked, and Indeterminate.

To set up a cell as TypeCheckbox, use code such as this in the Open event:
Me.CellType(1, 0) = ListBox.TypeCheckBox

To change the state of the cell, use the CheckedStates enum of the CheckBox control:
ListBox1.CellState(1, 0) = Checkbox.CheckedStates.Indeterminate

The Indeterminate state places a minus sign in the checkbox (Macintosh) or fills in checkbox (Windows and Linux). [/code]

I stop here because I do not want to make a whole copy of the Language Reference.

NOW SOME CODE from the given Listbox link:

In Listbox.CellAction:

If column = 0 Then // Is this the CheckBox column? If Me.CellCheck(row, column) Then Me.RemoveRow(Row) End If End If

In Window.Open (Or can be set in LB.Open):

LB.ColumnCount = 5 LB.AddRow "" LB.CellType(0,0) = ListBox.TypeCheckBox

Run, Click in the only Row’s CheckBox delete (Remove) that Row.

Now you can adapt the code above to your needs.

my goal is to select the row to be deleted by checking checkbox than i press the delete button to erase the checked row from the LB.
Any way you give me enough explanation to understand better the listbox subject.
Thank’s Emile

Replace Me.RemoveRow(Row) with Me.Selected(Row) [Check the code as I wrote it in the Firefox Tab] may do the trick.

Then in your button delete (in a loop as above) the selected Rows.

My code example taken from the Docs show a way o achieve the asked goal.

Good luck.