This question is locked. New answers and comments are not allowed.
I have a DataGridView that I want to use for editing records, with just a single attribute\column available for editing. However, the control that I present to the user for editing will change depending upon other attributes of the underlying record, for example on one row I may have a simple textbox, on another a combobox of available choices, etc.
I have been able to get the different controls displayed by definining ControlTemplates within the UserControl.Resources section as described elsewhere, however I can't then associated the values entered by the user with my underlying record. For example, when the SelectionChanged event is fired for a combobox, I have no visibility of which record\row the combobox belongs to. I've tried setting the Tag of the Binding object to be my record, but that crashes saying it can't be modified once it's used. Because I've replaced the edit control, I no longer get the CellEditEnded event firing so can't pick up events that way....
So in short, what is the solution for having custom ControlTemplates, assigned at runtime, and then re-binding back to the original data source?
I have been able to get the different controls displayed by definining ControlTemplates within the UserControl.Resources section as described elsewhere, however I can't then associated the values entered by the user with my underlying record. For example, when the SelectionChanged event is fired for a combobox, I have no visibility of which record\row the combobox belongs to. I've tried setting the Tag of the Binding object to be my record, but that crashes saying it can't be modified once it's used. Because I've replaced the edit control, I no longer get the CellEditEnded event firing so can't pick up events that way....
So in short, what is the solution for having custom ControlTemplates, assigned at runtime, and then re-binding back to the original data source?
