如何在我的委托中作为变量访问按钮的ImageIndex属性?

时间:2011-07-26 02:19:40

标签: c# button delegates properties

这适用于大多数所有控件,但我似乎无法公开ImageIndex属性。我不相信我想从我的代码访问ImageIndexConverter,它无论如何都不起作用。

delegate void SetControlImageIndex(Button oControl, ImageIndexConverter aIndex);

private void SetControlKey(Button oControl, ImageIndexConverter aIndex )
{
    // Check if the Invoke is required
    if (oControl.InvokeRequired)
    {
        // Create an instance of the delegate
        SetControlImageIndex a = new SetControlImageIndex(SetControlKey);
        // Invoke the delegate callback
        this.Invoke(a, new object[] { oControl,  aIndex });
    }
    else
    {
        // Invoke is not required...set the property
        oControl.ImageIndex = Convert.ToInt32(aIndex);
    }
}

0 个答案:

没有答案