PC Review


Reply
Thread Tools Rate Thread

BindingContext Question

 
 
Trecius
Guest
Posts: n/a
 
      11th May 2009
Hello, Newsgroupians:

I've another question regarding databinding. I have a TabControl with two
TabPages. Also -- for simplicity -- I have a ListBox and a TextBox in EACH
page.

I also have a List<Person> that I am using to populate the pages.

When the form loads, I populate each page...

this.Page1.BindingContext = new BindingContext();
this.ListBox1.DataSource = lstPersons;
this.TextBox1.DataBindings.Add("Text", lstPersons, "Name");

this.Page2.BindingContext = new BindingContext();
this.ListBox2.DataSource = lstPersons;
this.TextBox2.DataBindings.Add("Text", lstPersons, "Name");

You can note in the code that I gave each TabPage its own BindingContext, so
they don't share a common index; that is, if the selected item in one ListBox
changes, it won't reflect on the other page. Well, I run this code, and only
the FIRST PAGE changes with respect to the currently selected item in the
ListBox. The second page populates ListBox2, but when I select an item, it
does not reflect my selection in TextBox2.

However, if I do allow both pages to share the same BindingContext, when I
select an item in either ListBox, the textboxes change, but, again, if I
change the selected item on one page, it is reflected on the other page.

Any ideas what I should do? Thank you in advance.


Trecius
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BindingContext Question Trecius Microsoft C# .NET 4 12th May 2009 03:21 PM
bindingcontext question JohnR Microsoft VB .NET 2 12th Oct 2005 01:41 PM
BindingContext - question Agnes Microsoft VB .NET 2 5th Aug 2004 03:35 PM
BindingContext Ruben Alves Microsoft ADO .NET 2 21st Nov 2003 08:52 PM
bindingcontext Edwin Microsoft VB .NET 1 6th Oct 2003 08:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:56 AM.