我正在嘗試實作ScrollEventHandler,但我不斷收到以下錯誤:
無法將型別“System.Windows.Forms.ScrollEventHandler”隱式轉換為“System.EventHandler”
這是我的代碼:
zoomBar.Scroll = new ScrollEventHandler(this.zoomBar_Scroll);
這是方法:
private void zoomBar_Scroll(object sender, ScrollEventArgs e)
{
if ( e.OldValue > e.NewValue)
{
wChart.zoomMinus();
}
else
{
wChart.zoomPlus();
}
}
我認為這與 Microsoft 檔案中的內容完全一致,但我一定遺漏了一些東西。
這是滾動元資料的螢屏截圖

uj5u.com熱心網友回復:
試試這個:
zoomBar.Scroll = (sender, e) =>
{
if (e.OldValue > e.NewValue)
{
wChart.zoomMinus();
}
else
{
wChart.zoomPlus();
}
};
uj5u.com熱心網友回復:
我把滾動條事件和軌跡條事件弄糊涂了。ScrollEventsArgs不配。ScrollBar_ TrackBar但正如有人在評論中指出的那樣,檔案中有一個錯誤,表明ScrollEventsArgs可以使用,TrackBar但不能。
這是檔案的鏈接。
ScrollEventHandlerDelegate
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/418016.html
標籤:
