[Obsolete] Error when adding event

Nov 29, 2009 at 2:15 AM

I am creating a Ribbon application in C#. I tried to add an event. However, I got an error saying: No overload for '_TriangleEnable_OnExecute' matches delegate 'RibbonLib.Controls.Events.OnExecuteEventHandler'. I checked to make sure that I have all references included. I compared my current code with the code provided in the samples. However, I still cannot find the error. The following is code from Form1.cs.

 

using System;
using System.Windows.Forms;
using RibbonLib;
using RibbonLib.Controls;
using RibbonLib.Controls.Events;
using RibbonLib.Interop;

namespace _10_CheckBox
{
    public enum RibbonMarkupCommands : uint 
    {
        cmdDropDownTriangle = 1100,
        cmdButtonDropTriangleEnable = 1101,
        cmdButtonDropTriangleCalculate = 1102,
        cmdDropDownSquare = 1200,
        cmdButtonDropSquareEnable = 1201,
        cmdButtonDropSquareCalculate = 1202,
        cmdTabArea = 2001,
        cmdTabVolume = 2002,
        cmdGroup2DShapes = 3001,
        cmdGroupPrisms = 3002,
        cmdGroupSpheres = 3003,
    }

    public partial class Form1 : Form, IRibbonForm
    {
        private Ribbon _ribbon;
        private RibbonButton _TriangleEnable;
        private RibbonButton _TriangleCalculate;
        private RibbonButton _SquareEnable;
        private RibbonButton _SquareCalculate;

        public Form1()
        {
            InitializeComponent();

            _ribbon = new Ribbon();
            _TriangleEnable = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonDropTriangleEnable);
            _TriangleCalculate = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonDropTriangleCalculate);
            _SquareEnable = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonDropSquareEnable);
            _SquareCalculate = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonDropSquareCalculate);

            _TriangleEnable.OnExecute += new OnExecuteEventHandler(_TriangleEnable_OnExecute);
        }

        void _TriangleEnable_OnExecute(ref PropertyKey key, ref PropVariant currentValue, IUISimplePropertySet commandExecutionProperties)
        {
            this.textBox1.ReadOnly = false;
            this.textBox2.ReadOnly = false;
            this.textBox3.ReadOnly = true;
            this.textBox4.ReadOnly = true;
        }

        #region IRibbonForm Members

        public IntPtr WindowHandle
        {
            get
            {
                return this.Handle;
            }
        }

        public void RibbonHeightUpdated(int newHeight)
        {
            this.splitContainer1.SplitterDistance = newHeight;
        }

        #endregion

        private void Form1_Load(object sender, EventArgs e)
        {
            _ribbon.InitFramework(this);
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            _ribbon.DestroyFramework();
        }
    }
}

Can you help me?

 

Error 1 No overload for '_TriangleEnable_OnExecute' matches delegate 'RibbonLib.Controls.Events.OnExecuteEventHandler' C:\Users\Saikrishna\Documents\Visual Studio 2010\Projects\Area and Volume\10-CheckBox\Form1.cs 43 42

No overload for '_TriangleEnable_OnExecute' matches delegate 'RibbonLib.Controls.Events.OnExecuteEventHandler'

 

 

Coordinator
Nov 29, 2009 at 7:21 PM

The signature of the OnExecute event has changed. Get the latest version on the site and check the samples.

The current signature of the OnExecute event is:

<font size="2">

 

</font>

public delegate void OnExecuteEventHandler(PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties);

So your code should probably be:

void _TriangleEnable_OnExecute(PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
{
     ...
}

Nov 29, 2009 at 10:02 PM

Thanks. I downloaded the new code and the error is gone.