So I'm attempting to code a fully-automated DnD sheet, and for the Extra Bonus section I figured I'd use a DataGridView where the user can freely add new bonuses to their character (including its equipped state, its name, its affected value, and its bonus value).
Here's my class. The 3rd property is an enum with some placeholder values for the sake of testing it.
public class ExtraBonus
{
public bool isEquipped { get; set; }
public string bonusName { get; set; }
public AffectedValues.values affectedValue { get; set; }
public string bonus { get; set; }
}
Here's my list with some more pre-entered placeholder values:
public static List<ExtraBonus> list = new List<ExtraBonus>()
{
new ExtraBonus { isEquipped = true, bonusName = "Divine Smite", affectedValue = AffectedValues.values.Heavy, bonus = "+1d6"},
new ExtraBonus { isEquipped = false, bonusName = "Hexblade", affectedValue = AffectedValues.values.None, bonus = "+3"},
new ExtraBonus { isEquipped = true, bonusName = "Hex", affectedValue = AffectedValues.values.Light, bonus = "+1d8"}
};
And here is where the list is bound to my DataGridView:
var bindingList = new BindingList<ExtraBonus>(ExtraBonusList.list);
var source = new BindingSource(bindingList, null);
ExtraBonusesGridView.DataSource = source;
With this I currently get the following (don't mind the formatting):
This seems to work but the program returns an error message when it's attempting to fill the third column. Says the value in DataGridViewComboBoxCell isn't valid (paraphrasing because the actual error log is in french).
I've been looking up all kinds of tutorials and I just can't find anything for this. I want my 3rd property (an enum of possible values that can be affected) to be bound to this ComboBox column where the user can freely select which value gets affected by this bonus.
How can I do this?
Thanks!