这适用于大多数所有控件,但我似乎无法公开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);
}
}