I have a form with a list box and a few text boxes, when the user selects an item from the list box, i need the approptiate information to show up in the txt boxes and allow the user to edit it.
Here's my form Load event:
Private prt As New DataAccess.Part
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lc As System.Web.UI.WebControls.ListItemCollection = DataAccess.Part.GetListItems()
cboParts.DataSource = lc
lstParts.DataSource = lc
txtPartBefore.DataBindings.Add(New Binding("Text", prt, "PartNumBefore", True, DataSourceUpdateMode.OnPropertyChanged))
txtPartAfter.DataBindings.Add(New Binding("Text", prt, "PartNumAfter", True, DataSourceUpdateMode.OnPropertyChanged))
txtOperation.DataBindings.Add(New Binding("Text", prt, "Operation", True, DataSourceUpdateMode.OnPropertyChanged))
txtNotes.DataBindings.Add(New Binding("Text", prt, "Notes", True, DataSourceUpdateMode.OnPropertyChanged))
End Sub
And the SelectedIndexChange for the list box:
Private Sub lstParts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstParts.SelectedIndexChanged
Dim ctl As ListControl = DirectCast(sender, ListControl)
prt = DataAccess.Part.FetchByID(ctl.SelectedValue.value)
End Sub
I'm using VB.Net 2005, but can convert your suggestions from C# if needed ;)
Thanks Tony W