By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Listbox Problem

P: n/a
I have two virtually identical listbox controls on a tabPage in my
application. I bind a small datatable to each one when a new project
(my data) is selected from a treeview control (this works fine).

When I select the first project, the data is retrieved without a
problem and the datatables are properly bound to both listboxes. The
first listbox has a "SelectedIndexChanged" event wired to it which
also works fine.

Now, here's the wierd part: When I select a different project, the
data is retreived and the datatables are properly bound to both
listboxes. HOWEVER, the first listbox doesn't show the data!!!!! The
data IS THERE, but it's invisible!!! You can even select an item, and
the select even fires properly with the correct data.

EVEN WIERDER is that if I un-wire the "SelectedIndexChanged" event the
problem goes away!!!! Of course, now my select events don't work.

This is VERY strange.

Any help would be greatly appreciated.

Sincerely,
Glen Wolinsky
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Code might be nice...

-----Original Message-----
I have two virtually identical listbox controls on a tabPage in my

Nov 20 '05 #2

P: n/a
Hi Glen,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that when you change the datasource
from one table to another, the data will not show in the first listbox.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I can not reproduce the problem.
Here is my test code.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.ListBox1.DataSource = Me.DataSet11.Customers
Me.ListBox1.DisplayMember = "Address"
Me.ListBox2.DataSource = Me.DataSet11.Customers
Me.ListBox2.DisplayMember = "CompanyName"
Me.OleDbDataAdapter1.Fill(Me.DataSet11)
Me.OleDbDataAdapter2.Fill(Me.DataSet11)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.ListBox1.DataSource = Me.DataSet11.Employees
Me.ListBox1.DisplayMember = "FirstName"
Me.ListBox2.DataSource = Me.DataSet11.Employees
Me.ListBox2.DisplayMember = "LastName"
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MsgBox("ListBox1_SelectedIndexChanged")
End Sub

Please apply my suggestion above and let me know if it helps resolve your
problem.

Also can you povide a simple reproduce sample for us to do further
troubleshooting?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3

P: n/a
I fixed the problem by using the following code for both listbox
controls when initializing my form:

lbxAssignments.BindingContext = Me.BindingContext
lbxOtherAttys.BindingContext = Me.BindingContext

I have limited understanding as to what this does, but it fixed the
problem.

Thanks,
Glen

--------------------------
Numbers 6:24-26
--------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4

P: n/a
"Glen" <an*******@nospam.com> schrieb
I fixed the problem by using the following code for both listbox
controls when initializing my form:

lbxAssignments.BindingContext = Me.BindingContext
lbxOtherAttys.BindingContext = Me.BindingContext

I have limited understanding as to what this does, but it fixed
the problem.

Maybe this helps:
http://msdn.microsoft.com/library/de...chitecture.asp
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

P: n/a
Hi Glen,

Did the link Armin post help you?

If you still have any concern on this issue, please feel free to post here
and I will work on you with that.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #6

P: n/a
Yes, what I had time to go through was helpful.

Thanks,
Glen
--------------------------
Numbers 6:24-26
--------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.