Skip to content

Instantly share code, notes, and snippets.

@wtuts
Created June 25, 2014 14:18
Show Gist options
  • Save wtuts/e8ab9bea9fe4f93ab0a4 to your computer and use it in GitHub Desktop.
Save wtuts/e8ab9bea9fe4f93ab0a4 to your computer and use it in GitHub Desktop.
Listbox selected item
//Selection changed event handler for listbox
private void Selectionchanged_Eventhandler_of_Listbox(object sender, SelectionChangedEventArgs e)
{
//Get the data object that represents the current selected item
Resultclass myobject = (sender as ListBox).SelectedItem as Resultclass;
//Checking whether that it is not null
if (myobject != null)
{
//Now you can get the name and marks of selected student from the myobject
//Display the name and marks of Selected Student in the textblocks given below the listbox.
Studentnameblock.Text = myobject.name;
marksblock.Text = myobject.marks.ToString(); ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment