0
votes

I have a class named PlatypusInfo.

I call a method that returns an instance of that class:

PlatypusInfo pi;
. . .
pi = MammalData.PopulateplatypusData(oracleConnectionMainForm, textBoxPlatypusID.Text);
. . .
public static PlatypusInfo PopulateplatypusData(OracleConnection oc, String platypusID) {

    int platypusABCID = getABCIDForDuckBillID(oc, platypusID);
    platypusInfo pi = new platypusInfo();

...but get this err msg: "System.ArgumentException was unhandled Message=Cannot bind to the property or column platypusName on the DataSource. Parameter name: dataMember Source=System.Windows.Forms ParamName=dataMember"

...on this line of code:

textBoxPlatypusID.DataBindings.Add(new Binding("Text", pi, "platypusName"));

I'm thinking that with my code, the platypusName member of the PlatypusInfo class (the instance of which is "pi") should be assigned to textBoxPlatypusID's Text property.

So am I understanding this incorrectly, am I going about it wrong, or both?

2
Does the class PlatypusInfo have a public property named 'platypusName' of type string? - John Arlen
Can you post the code for PlatypusInfo - SwDevMan81
@John: Not exactly a property: public class PlatypusInfo { public String PlatypusName; - B. Clay Shannon
@John: I don't know how literally you meant "property" - B. Clay Shannon
@ClayShannon: Change it to a property, and make sure the case matches. - John Arlen

2 Answers

1
votes

You'll need to change it from a field to a property and add the implementation of the INotifyPropertyChanged interface. So something like this:

public class PlatypusInfo : INotifyPropertyChanged
{         
    public event PropertyChangedEventHandler PropertyChanged;
    private String _PlatypusName;

    public String PlatypusName 
    { 
       get
       {
          return _PlatypusName;
       }
       set 
       {
          _PlatypusName = value;
          NotifyPropertyChanged("PlatypusName");
       }
    }

    private void NotifyPropertyChanged(String info)
    {
       PropertyChangedEventHandler property_changed = PropertyChanged;
       if (property_changed != null)
       {
          property_changed(this, new PropertyChangedEventArgs(info));
       }
    }
}

Then the databinding would look like this:

textBoxPlatypusID.DataBindings.Add(new Binding("Text", pi, "PlatypusName"));

assuming pi is a PlatypusInfo object.

0
votes

Does the class PlatypusInfo implements the interface INotifyPropertyChanged