About Databinding of Listbox

S

Sidney

I tried to databind the listbox in vb.net with dataset
I wrote some code in the listbox selectedindexchanged event, however,
whenever the programme goes to the selectedindexchanged, it hanged and I
need to closed the whole system
it appear this problem also when i click a check box which the the
CheckedChanged event in the check box
need refreshing the dataset with another SQL code

Thanks a lot~

Sidney
 
C

Cor Ligthert [MVP]

Sidney,

This is not so much asked as in past. The selected index fires as soon as
you set the datasource to the listbox.

There are two solution:
Set a switch in your selectex index change event that you set to true as
every thing is initial set in your listbox

Add the handler as soon as everything set in the listbox.

The last (in my opinion the nicest) you can see how in the bottom of the
form load in this sample.

http://www.vb-tips.com/default.aspx?ID=771fdc2f-ecb7-48b6-a128-a5006c96efe4

Don't than forget the addhandler at the end of the event sub.

I hope this helps.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top