I'm loading students into my datagrid and then want to assign them to a class. I really don't care how exactly, but I can't get any method working.
I tried it with a context menu, but didn't manage to get the event (never worked with it before) Then I added a button in each row, but then I couldn't figure out how to get the row in which the button is. My last try was to get the selectedItem and use ToString() like on a combobox, but that didn't work either.
Check this out:
private void dataGrid4_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
DataGrid dg = new DataGrid();
dg = (sender as DataGrid);
MessageBox.Show(dataGrid4.Items.GetItemAt(1).ToString());
MessageBox.Show(dataGrid4.CurrentItem.ToString() + "\n" + dataGrid4.CurrentCell.Column.ToString() + "\n" + dataGrid4.CurrentCell.Item.ToString() + "\n" + dataGrid4.SelectedItem.ToString() + "\n" + dataGrid4.SelectedValue.ToString() + "\n" + dataGrid4.SelectedIndex.ToString());
MessageBox.Show(dg.CurrentItem.ToString() + "\n" + dg.CurrentCell.Column.ToString() + "\n" + dg.CurrentCell.Item.ToString() + "\n" + dg.SelectedItem.ToString() + "\n" + dg.SelectedValue.ToString() + "\n" + dg.SelectedIndex.ToString());
}
Please help me out, I'm about to freak out.. ):