G
Gordon Padwick
I am creating a WPF project (using Visual Studio 2008 Professional) that
gets data from an Access database table and displays that data in a ListBox
control. The database table contains three text columns and one memo column.
The ListBox uses a DataTemplate to display the four columns of data (as
explained in Microsoft's "How to: Bind to an ADO.NET Data Source).
At this point, I want to select a row in the ListBox and display the content
of the selected row in four separate text boxes so that they can be edited
and used in other parts of the project.
My window contains a button that, when clicked, calls a temporary event
handler that contains:
String curItem = myList.SelectedItem.ToString();
MessageBox.Show(curItem);
The message box of course displays "System.Data.DataRowView". I suspect I
need to override the ToString method to see the actual contents of the
selected ListBox item, but I don't understand how to create such an
override.
Visual Studio Help and the various books about C# and WPF that I've looked
at provide a lot of information about populating a ListBox control, but very
little about working with data in the control.
Can someone provide some hints about extracting data from a selected item in
a ListBox control? Thanks.
gets data from an Access database table and displays that data in a ListBox
control. The database table contains three text columns and one memo column.
The ListBox uses a DataTemplate to display the four columns of data (as
explained in Microsoft's "How to: Bind to an ADO.NET Data Source).
At this point, I want to select a row in the ListBox and display the content
of the selected row in four separate text boxes so that they can be edited
and used in other parts of the project.
My window contains a button that, when clicked, calls a temporary event
handler that contains:
String curItem = myList.SelectedItem.ToString();
MessageBox.Show(curItem);
The message box of course displays "System.Data.DataRowView". I suspect I
need to override the ToString method to see the actual contents of the
selected ListBox item, but I don't understand how to create such an
override.
Visual Studio Help and the various books about C# and WPF that I've looked
at provide a lot of information about populating a ListBox control, but very
little about working with data in the control.
Can someone provide some hints about extracting data from a selected item in
a ListBox control? Thanks.