:Edit: Now with Video!! Take a look at my third post, fourth post in total
Hello all,
This is my first post, so let me know if I need to add any more information. I have also done a quick search and found nothing
Scenario:
I have Checkbox and a list box, checking the checkbox should:
a) Enable the List box,
b) Run a SQL query against a MySQL database (and should return 2 rows),
c) The data returned should bind with the Listbox, using both Display and ValueMember.
When the checkbox is unchecked:
a) The Listbox is disabled,
b) The Listbox is emptied.
The problem:
Everything above works ok, but if after Checking, Unchecking and then checking again the list box not display any contents like it does when it is checked initially.
The checking/unchecking of the box makes no difference until the form is closed and re opened. On the form being re-opened the checkbox works for one cycle then stops.
The odd:
I placed a button on the form, that when clicked shows a message box stating the number of rows in the listbox.
On form load the msgbox states 0
After checking the checkbox the msgbox states 2 and the listbox has two items (correct as the DB only has two items at the moment)
After unchecking the checkbox the msgbox states 0 and the listbox is empty
After checking the checkbox (again) the msgbox states 2 but the list box is empty!
The code is setup with a checkbox_CheckedChanged sub and a function called 'loadlistbox'.
the _CheckedChanged sub basically calls the function and passes a few parameters, one of which is the status of the checkbox.
If the Function gets the status as 'checked' it created the db connection runs the sql and sets the listbox.DataSource as the returned MySqlDataAdapter
If the Function gets the status as 'unchecked' it sets the listbox.DataSource = Nothing and the clears the listbox via listbox.items.clear
Can any kind soul help me figure out why the list box does not physically display the items on a 're-check' of the box but the listbox.items.count still sees them!
I can post code if needed. Please feel free to move this if it is in the wrong section!
Thanks, and kind regards.
Cobalt
Hello all,
This is my first post, so let me know if I need to add any more information. I have also done a quick search and found nothing
Scenario:
I have Checkbox and a list box, checking the checkbox should:
a) Enable the List box,
b) Run a SQL query against a MySQL database (and should return 2 rows),
c) The data returned should bind with the Listbox, using both Display and ValueMember.
When the checkbox is unchecked:
a) The Listbox is disabled,
b) The Listbox is emptied.
The problem:
Everything above works ok, but if after Checking, Unchecking and then checking again the list box not display any contents like it does when it is checked initially.
The checking/unchecking of the box makes no difference until the form is closed and re opened. On the form being re-opened the checkbox works for one cycle then stops.
The odd:
I placed a button on the form, that when clicked shows a message box stating the number of rows in the listbox.
On form load the msgbox states 0
After checking the checkbox the msgbox states 2 and the listbox has two items (correct as the DB only has two items at the moment)
After unchecking the checkbox the msgbox states 0 and the listbox is empty
After checking the checkbox (again) the msgbox states 2 but the list box is empty!
The code is setup with a checkbox_CheckedChanged sub and a function called 'loadlistbox'.
the _CheckedChanged sub basically calls the function and passes a few parameters, one of which is the status of the checkbox.
If the Function gets the status as 'checked' it created the db connection runs the sql and sets the listbox.DataSource as the returned MySqlDataAdapter
If the Function gets the status as 'unchecked' it sets the listbox.DataSource = Nothing and the clears the listbox via listbox.items.clear
Can any kind soul help me figure out why the list box does not physically display the items on a 're-check' of the box but the listbox.items.count still sees them!
I can post code if needed. Please feel free to move this if it is in the wrong section!
Thanks, and kind regards.
Cobalt
Last edited: