J
JohnR
I have a question on bindingcontext, bindings, and
controlbindingscollection. 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.datasource 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.databindings.add(new binding("text", ds.tables("customer"),
"Name"))
combobox.datasource = ds.tables("customer")
textbox.databindings.add(new binding("text", ds.tables("customer"),
"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.datasource =
ds.tables("customer"). 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
controlbindingscollection. 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.datasource 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.databindings.add(new binding("text", ds.tables("customer"),
"Name"))
combobox.datasource = ds.tables("customer")
textbox.databindings.add(new binding("text", ds.tables("customer"),
"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.datasource =
ds.tables("customer"). 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