AnsweredAssumed Answered

How to resolve DataGridViewComboBox data error with Digital Set?

Question asked by andrew_Inwood on Apr 8, 2020
Latest reply on Apr 9, 2020 by andrew_Inwood

I am trying to build a digital point state selector using a WinForms DataGridViewComboBoxColumn, binding it to the AFEnumerationSet for digital points.  It works fine, but I keep getting a DataError raised by the DataGridView.  


I have been playing around trying to ensure that the DataType is compatible, but no luck.  Note that it still adds the list of values from the enumeration set properly, displays them properly, and sets the correct Current value of the tag.  It also handles the UpdateValue() method perfectly, it is purely that I am uncomfortable with having a DataError raised every time the cell is displayed.


if (PIServer != null && PIServer.ConnectionInfo.IsConnected)
    PIPoint = PIPoint.FindPIPoint(PIServer, piTag);
    if (PIPoint.PointType == PIPointType.Digital)
        // PIPoint.CurrentValue().GetType();

        AFEnumerationSet set = PIPoint.GetStateSet();
        this.DataSource = set;
        this.DisplayMember = "Name";
        this.ValueMember = "Value";

        AFEnumerationValue value = set[PIPoint.CurrentValue().ValueAsInt32()];
        this.ValueType = value.GetType();
        this.Value = value;
        this.DataSource = new List<string>() { "Point is not digital;" };

Note - in this example 'this' is a DataGridViewComboBoxCell.


I then update the point when the CellValue changes:

AFValue pointValue = new AFValue(view.CurrentCell.Value);
PIPoint.UpdateValue(pointValue, OSIsoft.AF.Data.AFUpdateOption.Replace);


Any guidance on resolving this error?