473,756 Members | 5,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bindingcontext question

I have a question on bindingcontext, bindings, and
controlbindings collection. I understand the very basic idea, and I think I
should be able to do this, but I'm not sure how.

First problem: I have a combobox and a textbox on a form. I also have a
"Customers" table loaded into a dataset. I set the combobox.dataso urce to
the table in the dataset, and add a binding to the text property of the
combobox for the 'Name' field. I also add a binding to the textbox.text
property for 'Address' like this:
combobox.databi ndings.add(new binding("text", ds.tables("cust omer"),
"Name"))
combobox.dataso urce = ds.tables("cust omer")
textbox.databin dings.add(new binding("text", ds.tables("cust omer"),
"Address"))

When run the combobox has the first name in the table, and the proper
address. I can use the dropdown to select a new name, but when I do the
address in the textbox does not change. Question: what do I need to do to
get the textbox to display the correct address after selecting a name in
the combobox?

Second Situation: I would like to present data in 2 different ways, each
presentation would be on a different 'tab' . The first presentation would
basically be what I said before.. a combobox for selecting a record, and a
bunch of textboxes that list the info for the record selected in the
combobox. The second tab screen would be in the form of a datagrid that
lists all of the records. I would do a datagrid.dataso urce =
ds.tables("cust omer"). Here is where I'm a little confused... how can I
link the 2 views of the data. That is, when on the data grid, if the user
selects a row or a cell, and then switches back to the 1st view, the record
he chose in the datagrid is the record that will be displayed in the
combobox and textboxes. Likewise, if the user selects a record in the
combobox and switches to the datagrid tab, the row selected in the grid will
be the record he chose in the combobox.

Is there some way to do this synchronization automatically via the
currencymanager or databindings? Or is it something that needs to be done
manually.

Thanks for any advise... I'm still learning!

John

Nov 21 '05 #1
2 2012
JohnR,

I never succeeded in binding the text in a combobox.

If you succeed (completely) give than a message.

This is one of the few problems that I have asked help for in this newsgroup
and the newsgroup vb.controls. I seldom got an answer, some of them did not
even get a reply and the replies did not help me.

In some situations it will help if you use the selectedvalue property.
However, as well not in all. It depend as well what event you use.

Therefore don't expect to much help here in this binding question about the
combobox. (You can use dummy textboxes than it works)

In my opinion it can really act very strange.

Cor
Nov 21 '05 #2
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:2QZ2f.1126 $t43.578@trndny 02...
I have a question on bindingcontext, bindings, and
controlbinding scollection. I understand the very basic idea, and I think I
should be able to do this, but I'm not sure how.

First problem: I have a combobox and a textbox on a form. I also have a
"Customers" table loaded into a dataset. I set the combobox.dataso urce to
the table in the dataset, and add a binding to the text property of the
combobox for the 'Name' field. I also add a binding to the textbox.text
property for 'Address' like this:
combobox.databi ndings.add(new binding("text", ds.tables("cust omer"),
"Name"))
combobox.dataso urce = ds.tables("cust omer")
textbox.databin dings.add(new binding("text", ds.tables("cust omer"),
"Address"))

When run the combobox has the first name in the table, and the proper
address. I can use the dropdown to select a new name, but when I do the
address in the textbox does not change. Question: what do I need to do to
get the textbox to display the correct address after selecting a name in
the combobox?
If i understand i right, you don't need to bind the Text property of the
ComboBox but use the DisplayMember instead. You also have to bind the
ComboBox and TextBox to the same DataSource (either DataSet or DataTable,
don't mix them).

eg:

combobox.DataSo urce = ds.Tables("cust omer")
combobox.Displa yMember = "Name"

textbox.DataBin dings.Add( "Text", ds.Tables("cust omer"), "Address" )

Both are bound to the same DataTable (customer part of the DataSet).
Therefore they will share the same CurrencyManager and they will navigate
together.

Second Situation: I would like to present data in 2 different ways, each
presentation would be on a different 'tab' . The first presentation would
basically be what I said before.. a combobox for selecting a record, and
a bunch of textboxes that list the info for the record selected in the
combobox. The second tab screen would be in the form of a datagrid that
lists all of the records. I would do a datagrid.dataso urce =
ds.tables("cust omer"). Here is where I'm a little confused... how can I
link the 2 views of the data. That is, when on the data grid, if the user
selects a row or a cell, and then switches back to the 1st view, the
record he chose in the datagrid is the record that will be displayed in
the combobox and textboxes. Likewise, if the user selects a record in
the combobox and switches to the datagrid tab, the row selected in the
grid will be the record he chose in the combobox.
Same here, just bind the DataGrid to the same DataSource, remember we used a
DataTable for the TextBox and ComboBox, so we have to do the same for the
DataGrid :

datagrid.DataSo urce = ds.Tables("cust omer")

Is there some way to do this synchronization automatically via the
currencymanager or databindings? Or is it something that needs to be done
manually.
If you bind different Controls to the (exact) same DataSource and the
Controls have the same BindingContext (which is the default within a Form)
then they will share the same CurrencyManager and navigate together.

HTH,
Greetings

Thanks for any advise... I'm still learning!

John

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1285
by: Carl | last post by:
Hi, I am trying to figure out the best approach for this simple scenario. I have one C# Windows application Form that consumes few web services for all data related function. In this form I do have few fields bind to the dataset DS , return from the WEB service.
1
3320
by: D. Yates | last post by:
Hi, I retrieved the employee table from the Pubs database into a single dataset called, dataSet12. I dropped two textbox controls and a datagrid control onto the same form and bound the controls at design time to dataSet12's employee table. Now I want to move through the data by pressing a button.... This code will change the data in the text boxes: this.BindingContext.Position += 1;
0
1824
by: Nathan Carroll | last post by:
Attempting to eliminate flicker showing (form) and hiding seems to have no effect as I have it below. if I move the lines: Me.Show() Me.ShowInTaskbar = True f.Close() to the end of the load procedure the flicker goes away and produces effects that destroy my multiple binding scheme. This Line: Me.CurrentDate.Text = CStr(Now) is has a problem with
1
7573
by: Edwin | last post by:
Hi, I created a dataform with the data form wizard which created some textboxes and 1 checkbox. When I add a row (see section "Add Row" for code) the newly added is not accessible. A label "lblNavLocation" generated by the wizard shows that a row has been added but I can not navigate to it. See section "PositionChanged" for code.
0
1089
by: Donald | last post by:
Mostly, I get the currencymanager from the form.bindingcontext property. but I found that I can aslo get the same currencymanager from a textbox.bindingcontext, even though this textbox does not have any bindings assoicated with this control. Why? // form currencymanager cm1 = (CurrencyManager) this.bindingcontext // textbox currencymanager, In fact, textbox1 does't have any databindings. cm2= (CurrencyManager)...
0
1396
by: nina98765 | last post by:
Hi all I have a data-bound Windows form bound to a strongly-typed dataset. Upon opening the form, I would like to Find a specific record based on a parameter I've passed to the form, and display the data in the appropriate textboxes, etc. I would also like to have the entire table opened (i.e., not just the one record I've found) as I would like to navigate through the records My table is called "AP_TBL_Vendors. The problem is that I...
4
1553
by: graham | last post by:
Hi all, I have a strange one, and being new to .NET, not sure if this is a bug and whether there is a work around. I have a form with databound textboxes.. In me general decs... Dim bmbLinkMAN As BindingManagerBase
6
2250
by: Aaron Smith | last post by:
I have a form, oddly enough the same one with the expression column that is giving me a headache, and on this form I have a dataset that has a couple of tables in it that are related. If I do a AddNew on the Binding Context for the parent, it doesn't seem to work. If I click the new (just does an addnew, and thats it) the fields do not clear out, and if I click new again, it just says that the first field that doesn't allow nulls, doesn't...
6
12140
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is contained in and thus all other controls on the parent form. (I want various controls on the form to...
0
9454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10028
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9868
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9707
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3352
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2664
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.