473,395 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Listbox Problem

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
6 1308
Code might be nice...

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

Nov 20 '05 #2
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
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brian | last post by:
Hi, All, I'm using MS.net 2003 and using a windows.forms.listbox control for my window application but I don't know why the Horizontal Scrollbar could NOT be shown even if I set...
5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
1
by: Josema | last post by:
Hi to all, I have a class (persons) that derives from collection base: and another class (person) with this properties: -ID -Name When i have complete filled the object Persons with all...
1
by: MrNobody | last post by:
Hi, I'm doing something where I add custom objects to a ListBox which have aToString() method overriden so it displays what I want. When adding instances of these custom objects to the ListBox I...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
15
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.