I've got a form with several controls on it, the values for which come from an XML file. This file needs to be updated as the user modifies the values in the controls and then saves.
Currently I've got all the textboxes and checkboxes working by adding bindings, like so:
Then I call questionBinding.WriteValue() to save changes.
I'm struggling with the comboboxes though. What I need is to have a static list of items in each combobox, with the comboboxes bound via their SelectedValue property to the datasource.
This is what I've got at the moment -
But this isn't working. Changing the property to be bound in AnsTypeBinding to "text" displays what's in the datasource - but this isn't what needs to be displayed.
Any pointers would be much appreciated.
Currently I've got all the textboxes and checkboxes working by adding bindings, like so:
VB.NET:
Dim bs As New BindingSource bs.DataSource = theDS.Tables(0)
questionBinding = New Binding("Text", bs, "Question", True, DataSourceUpdateMode.Never)
txtQuestion.DataBindings.Add(questionBinding)
Then I call questionBinding.WriteValue() to save changes.
I'm struggling with the comboboxes though. What I need is to have a static list of items in each combobox, with the comboboxes bound via their SelectedValue property to the datasource.
This is what I've got at the moment -
VB.NET:
Dim item1 As New ComboItem
item1.text = "Free Text"
item1.SelectedValue = "TextBox"
cmbAnsType.Items.Add(item1)
AnsTypeBinding = New Binding("SelectedValue", bs, "AnswerFormat", True, DataSourceUpdateMode.Never)
AnsTypeBinding.ReadValue()
cmbAnsType.DataBindings.Add(AnsTypeBinding)
But this isn't working. Changing the property to be bound in AnsTypeBinding to "text" displays what's in the datasource - but this isn't what needs to be displayed.
Any pointers would be much appreciated.