Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hai

I am having a textbox,listbox and button control.In the list box control multiselectoption to true.After click on button event values are inserted into database.But the selected listbox items is still in select mode.How can i clear this.

Thanks in advance.
Posted

Hi,

Once list values are inserted,
you should call this code to set all items selected == false

ListBox1.ClearSelection();

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
Comments
Member 10234093 12-Dec-13 7:51am    
Thanks.i got it.
♥…ЯҠ…♥ 12-Dec-13 8:17am    
Welcome....
UFONE1 2-May-20 17:43pm    
Another way is to use click event of the list box , if we do not want to double click the one list box item for the deselection of another list items.
ex:


private void ListBox_Right_Click(object sender, EventArgs e)
{
Btn_Left.Enabled = ListBox_Right.SelectedIndex >= 0;
ListBox_Left.ClearSelected();
Btn_Right.Enabled = false; // for my specification
}
}



private void ListBox_Left_Click(object sender, EventArgs e)
{

Btn_Right.Enabled = ListBox_Left.SelectedIndex >= 0;
ListBox_Right.ClearSelected();

Btn_Left.Enabled = false;// for my specification
}
Write a on click event to save to the database, once the items have saved in the database, set the selected attribute to false ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900