I am attempting to create a databinding between a numericupdown and an array element. In my form I have tried creating the binding shown below, but it doesn't seem to work. Any help would be appreciated.
Binding:
nudTest.DataBindings.Add("Value", eac.ESettings.HsvArray[0], "", false,DataSourceUpdateMode.OnPropertyChanged);
Array:
public class ESettings : INotifyPropertyChanged
{
private int[] hsvArray = new int[6];
public event PropertyChangedEventHandler PropertyChanged;
[XmlIgnore]
public bool PrgVarIsDirty
{
get { return prgVarIsDirty; }
set
{
prgVarIsDirty = value;
OnPropertyChanged("PrgVarIsDirty");
}
}
public int[] HsvArray
{
get { return hsvArray; }
set
{
if (value != hsvArray)
{
prgVarIsDirty = true;
hsvArray = value;
OnPropertyChanged("HsvArray");
}
}
}
// Create the OnPropertyChanged method to raise the event
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
}