Can't get this work properly:

FormatRange(ref ws.Range[curRange.Offset[1, 0] , gives A property or indexer may not be passed as an out or ref parameter

Any help would be thankfull

public static void WriteDetailData(ref Worksheet ws, string type, ref int row, int col, Hashtable parts, Hashtable refList)


            {


            Range curRange = null;
            Component component = null;

            curRange = ws.Cells[row, col];

            curRange.Value = type + "Component Summary";
            FormatRange(ref curRange, 10, "Green", true, false, false, XlHAlign.xlHAlignLeft);
            curRange.Font.Underline = true;

            curRange.Offset[1, 0].Value = "Ref-Desig";
            curRange.Offset[1, 1].Value = "Part Number";
            curRange.Offset[1, 2].Value = "Shape Code";
            curRange.Offset[1, 3].Value = "Type";
            curRange.Offset[1, 4].Value = "Side";
            curRange.Offset[1, 5].Value = "Pin Count";
            FormatRange(ref ws.Range[curRange.Offset[1, 0], curRange.Offset[1, 5]], 9, "Red", true, false, true, XlHAlign.xlHAlignCenter);

            row += 2;

            foreach (Component component_loopVariable in parts.Values)
            {
                component = component_loopVariable;
                curRange = (Range)ws.Cells[row, 1];
                curRange.Value = component.RefDes;
                curRange.Offset[0, 1].Value = refList[component.RefDes];
                curRange.Offset[0, 2].Value = component.Package.Name;
                curRange.Offset[0, 3].Value = component.Package.MountType;
                curRange.Offset[0, 4].Value = component.Side.ToString().Substring(4);
                curRange.Offset[0, 5].Value = component.Package.Pins.Count;

                FormatRange(ref ws.Range[curRange.Offset[0, 1], curRange.Offset[0, 5]], 9, "Black", false, false, true, XlHAlign.xlHAlignLeft);
                row += 1;
            }

Recommended Answers

All 2 Replies

The error is very clear, you can't have a ref parameter that's a property. Copy the value of the property into a temporary variable, then after the method returns, copy that temporary variable's value back to the propery.

Thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.