Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datasource question

Status
Not open for further replies.

tzzdvd

Programmer
Aug 17, 2001
52
IT
I've just found a very strange behaviour about the datasource property of the listbox.
Here is the code:
Code:
public partial class SpeedSelection: Form
{
   public SpeedSelection(int[] Speed)
   {
      InitializeComponent();
      listSpeedTx.DataSource = Speed;
      listSpeedRx.DataSource = Speed;
   }
}
Every time I select a different value of (for example) the listSpeedTx control, immediatly the same listSpeedRx value is selected.
Where is the link?
The obvious relationship is that both controls have the same datasource but why this behaviour?
The solution I find is that:
Code:
public partial class SpeedSelection: Form
{
   public SpeedSelection(int[] Speed)
   {
      InitializeComponent();
      listSpeedTx.Items.AddRange(Speed);
      listSpeedRx.Items.AddRange(Speed);
   }
}
... and the link immediatly disappears.

Maybe there should be a link on the data but the link on the selection of the data is very strange.
Anyone has an answer?

Thank's
Davide
 
What do the events codes look like for these two list boxes? Are the event handler pointing to the same code?
 
This beahaviour happens without any kind of event handler.
 
First, I haven't built a test example for myself and you may want to check this out in more detail dependant on what version of the .Net Framework you're compiling against.

I would figure though that the second list box is responing to the change in SelectedItem(s) of its bound DataSource, (which is the same DataSource as the first ListBox where you're selecting an item), in example one, while in example two you're simply adding a range of ListItems to each list box seperately and there's no relationship between the ranges added as although they're from the same DataSource, the controls aren't bound.

Rhys
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense Edsgar Dijkstra

Church of the Flying Spaghetti Monster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top