Well the answer to your first question is yes. It can be done. If I
understand your question, you are wanting to bind a ComboBox to a data
class. I think the syntax that you are looking for is as follows:
ComboBox1.Databindings.Clear
ComboBox1.Databindings.Add ("SelectedItem", objDataClass,
"myDataClassProperty")
That's about it. I hope it helps. This is called simple databinding.
There is also complex databinding.
--
Dean
"Mike Hofer" <(E-Mail Removed)> wrote in message
news:bBDcb.14914$AH4.4423@lakeread06...
> I am trying to do something a little nonstandard, and am having some
> difficulty determining (a) if it can be done and (b) if so, how to do it.
>
> What I want to do is fill a dropdown combobox with data from a collection.
> Then, I want to bind that list to a member of a custom class. (Don't ask
> why, just trust me on that one. <gr>).
>
> What I'm doing now is binding the combo box to a collection, as follows:
>
> Dim items As ArmorTypeCollection = ArmorTypeDac.Select()
> With Me.ArmorType
> .DataSource = items
> .DisplayMember = "Value"
> .ValueMember = "ID"
> End With
>
> Then, when the data is loaded onto the form, I set the default member as
> follows:
>
> Dim item As ArmorType
> For Each item In ArmorType.Items
> If item.ID.ToString() = _armor.Type.ID.ToString() Then
> ArmorType.SelectedItem = item
> Exit For
> End If
> Next
>
> When the user commits her changes, I load them back into the object as
> follows:
>
> _armor.Type = ArmorTypeDac.Select().Item(Me.ArmorType.SelectedValue())
>
> Is there a better way to do this? Essentially, my _armor object (of type
> Armor) has a reference to an item in the armor type collection.
>
> Any help would be greatly appreciated.
>
>
|