Wednesday, 3 July 2013

Accessing (AXBound) Bound Field Properties

///

    /// Code to get Field from Grid. Mallik
    ///

    ///
    ///
    ///
    static AxBoundField GetField(DataControlFieldCollection fields, string name)
    {
        foreach (DataControlField field in fields)
        {
            // Is this the field being searched for?
            AxBoundField boundField = field as AxBoundField;
            if (boundField != null && String.Compare(boundField.DataField, name, true) == 0)
            {
                return boundField;
            }
        }
        // Nothing found, so return null.
        return null;
    }

--------------------------------------------------------------------------------------------------------------------------
The following example uses the method created above to set the ReadOnly property for the SalesQty bound field in the AxGridView1  grid object for an AxForm.
-------------------------------------------------------------------------------------------------------------------------
AxBoundField RelatedSalesQty;
        AxBoundField RelatedSalesUnit;
        try
        {
            row = this.GetCurrentRow;
            authorizationStatus = row.GetFieldValue("AvaAuthorizationStatus").ToString();
            if (authorizationStatus == "0")//Labels.GetLabel("@AVA114"))
            {
                AxGridView1.AllowEdit = true;
                AxGridView1.AllowDelete = true;
                AxGridView1.AutoGenerateEditButton = true;
               
                RelatedSalesQty = GetField(AxGridView1.Columns, "SalesQty");
                RelatedSalesQty.ReadOnly = false;
                RelatedSalesUnit = GetField(AxGridView1.Columns, "SalesUnit");
                RelatedSalesUnit.ReadOnly = false;
                //AxGridView1.Columns.Contains("SalesQty")
                ret = true;
            }

No comments:

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...