I have a DataGridViewComboBoxColumn where I'm supposed to display different values than are selected, much like what's going on in this question:
http://stackoverflow.com/questions/1390462/datagridviewcomboboxcolumn-name-value-how
In my case, I'm displaying lists of equipment which have an ID and a description. So my bound data class looks like this:
public class AURecord
{
// member vars and constructors omitted for brevity
public string ID { get { return _id; } }
public string Description { get { return _description; } }
public string FullDescription
{
get { return string.Format("{0} - {1}", _id, _description); }
}
}
So I have the DisplayMember and ValueMember set up to be the FullDescription and the ID, respectively. So far so good.
The problem is, the requirements call for the FullDescription to be displayed in the drop list, but once a selection is made only the ID should appear in the text box (the description is to be displayed in a neighboring read-only column, and I have that working as well).
I'm hoping for a solution that only involves changing some properties on the DataGridViewComboBoxColumn object in my grid, though I fear the answer will be more along the lines of creating a DataGridViewComboBoxColumn subclass and doing a bunch of overloading (ugh)...