Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ .NET Managed
This part. Commented code is cs.
On compile catch an error:
Error 78 error C3766: 'Sample::NoteInfo' must provide an implementation for the interface method 'System::String ^System::ComponentModel::IDataErrorInfo::default::get(System::String ^)' d:\dev\docstreet\sample\pointInfoStoreClass.h 100

What's incorrect? Why VS compiler consider this not implemented?
#pragma region IDataErrorInfo Members
 
<pre>
    //Returns an error description set for the item's property
    //String^ IDataErrorInfo.this[String^ columnName] {
    //  get {
    //      return GetColumnError(columnName);
    //  }
    //}

    public: property String^ IDataErrorInfo[String^] {
        virtual String^ get(String^ index) override {
            return GetColumnError(index);
        }
    }

Full code:
public ref class NoteInfo : IDataErrorInfo {
        int fDay;
        int fMonth;
        int fYear;
        int fNoteID;
        //References the item's owner
        ProjectNotes^ owner;
        //Stores error descriptions for the Day, Month, Year and NoteID properties
        Hashtable^ propertyErrors;
        //Stores an error description for the item
        String^ fNoteError;
 
<pre>
public: NoteInfo(int noteID, int day, int month, int year) {
        fNoteID = noteID;
        fDay = day;
        fMonth = month;
        fYear = year;
        //Set errors to empty strings
        propertyErrors = gcnew Hashtable();
        propertyErrors-&gt;Add(&quot;Day&quot;, &quot;&quot;);
        propertyErrors-&gt;Add(&quot;Month&quot;, &quot;&quot;);
        propertyErrors-&gt;Add(&quot;Year&quot;, &quot;&quot;);
        propertyErrors-&gt;Add(&quot;NoteID&quot;, &quot;&quot;);
        fNoteError = &quot;&quot;;
        Owner = nullptr;
    }
 
public: property int NoteID {
        int get() { return fNoteID; }
        void set(int value) {
            if(fNoteID == value) return;
            fNoteID = value;
        }
    }
 
public: void ClearErrors() {
        SetColumnError(&quot;Day&quot;, &quot;&quot;);
        SetColumnError(&quot;Month&quot;, &quot;&quot;);
        SetColumnError(&quot;Year&quot;, &quot;&quot;);
        fNoteError = &quot;&quot;;
    }
 
    //Sets an error for an item's property
public: void SetColumnError(String^ elem, String^ error) {
        if(propertyErrors-&gt;ContainsKey(elem)) {
            if((String^)propertyErrors[elem] == error) return;
            propertyErrors[elem] = error;
        }
    }
 
    //Gets an error for an item's property
public: String^ GetColumnError(String^ elem) {
        if(propertyErrors-&gt;ContainsKey(elem))
            return (String^)propertyErrors[elem];
        else
            return &quot;&quot;;
    }
 
    //The owner collection
internal: property ProjectNotes^ Owner {
        ProjectNotes^ get() { return owner; }
        void set(ProjectNotes^ value) { owner = value; }
    }
 

pragma region IDataErrorInfo Members

 
    //Returns an error description set for the item's property
    //String^ IDataErrorInfo.this[String^ columnName] {
    //  get {
    //      return GetColumnError(columnName);
    //  }
    //}

    public: property String^ IDataErrorInfo[String^] {
        virtual String^ get(String^ index) override {
            return GetColumnError(index);
        }
    }
 
    //Returns an error description set for the current item
public: property String^ Error {
        virtual String^ get() { return fNoteError; }
 
    }
 

pragma endregion

 
};</pre>
Posted 29-Nov-12 1:17am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Found the solution
 
public: property String^ default[String^] {
            virtual String^ get(String^ index) {
                return GetColumnError(index);
            }
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 335
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200
0 OriginalGriff 465
1 Sergey Alexandrovich Kryukov 275
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200


Advertise | Privacy | Mobile
Web04 | 2.8.150331.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100