checked list box checked data pass to listview [ with if uncheck it is removed ]

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi [again]
in my previous thread i have been given a suggestion to rethink on how i would do my form.<br/>
so i did.
well, my form contains
a checked list box [data coming from the database]
a combo box [bind to a database table product]
and a listview [ was previously a listbox ]

what my form is doing <br/>
when a user clicks on the item in the checked list box
it should transfer to the listbox<br/>
and when the item is unchecked<br/>
it is removed from the listbox<br/>
<br/>
is that possible with the listview?
i was using this code for the if check[add]/uncheck[remove] from listbox

<div style="color:black; background-color:white
<pre><span style="color:blue Private <span style="color:blue Sub CheckedListBox1_ItemCheck(<span style="color:blue ByVal sender <span style="color:blue As <span style="color:blue Object, <span style="color:blue ByVal e <span style="color:blue As System.Windows.Forms.ItemCheckEventArgs) <span style="color:blue Handles CheckedListBox1.ItemCheck

<span style="color:blue If e.NewValue = CheckState.Checked <span style="color:blue Then
<span style="color:blue If <span style="color:blue Not ListBox1.Items.Contains(CheckedListBox1.Items(e.Index)) <span style="color:blue Then
ListBox1.Items.Add(CheckedListBox1.Items(e.Index))
<span style="color:blue End <span style="color:blue If


<span style="color:blue ElseIf e.NewValue = CheckState.Unchecked <span style="color:blue Then

<span style="color:blue If ListBox1.Items.Contains(CheckedListBox1.Items(e.Index)) <span style="color:blue Then
ListBox1.Items.Remove(CheckedListBox1.Items(e.Index))


<span style="color:blue End <span style="color:blue If

<span style="color:blue End <span style="color:blue If

<span style="color:blue End <span style="color:blue Sub
[/code]


<br/>
and this to add the item value [ mi = mat_id , mat_name declared in a class, as per suggested in one of my answered thread]

<div style="color:black; background-color:white
<pre><span style="color:blue Private <span style="color:blue Sub CheckedListBox1_SelectedIndexChanged(<span style="color:blue ByVal sender <span style="color:blue As System.Object, <span style="color:blue ByVal e <span style="color:blue As System.EventArgs) <span style="color:blue Handles CheckedListBox1.SelectedIndexChanged
ListBox1.Items.Clear()

<span style="color:blue For <span style="color:blue Each mi <span style="color:blue As MatItem <span style="color:blue In CheckedListBox1.CheckedItems
ListBox1.Items.Add(mi)
<span style="color:blue Next
<span style="color:blue End <span style="color:blue Sub
[/code]

<br/>
<br/>
or any suggestion would be appreciated to do this.<br/>
<br/>
the data in the listview would be saved into a database table called formula

<br/>

View the full article
 
Back
Top