您無需再次聲明該事件。如果它是公共的并且在需要時已經(jīng)被拋出,您可以根據(jù)需要通過訂閱基類事件來處理更改。我的意思是,您可以執(zhí)行以下操作:using System;using System.Windows.Forms;namespace DRT{ internal abstract partial class DRT_ComboBox_Abstract : ComboBox { public DRT_ComboBox_Abstract() { InitializeComponent(); SelectedValueChanged += MyOwnHandler } protected virtual void MyOwnHandler(object sender, EventArgs args) { // Hmn.. now I know that the selection has changed and can so somethig from here // This method is acting like a simple client } }}在S O LID類上(我相信 是這種情況ComboBox),通常有效調(diào)用訂閱者來處理某些事件的方法通常是虛擬的,一旦您從此類繼承,就允許您攔截事件處理程序調(diào)用,如果這是你想要的。這是:using System;using System.Windows.Forms;namespace DRT{ internal abstract partial class DRT_ComboBox_Abstract : ComboBox { public DRT_ComboBox_Abstract() { InitializeComponent(); } protected override void OnSelectedValueChanged(object sender, EventArgs args) { // Wait, the base class is attempting to notify the subscribers that Selected Value has Changed! Let me do something before that // This method is intercepting the event notification // Do stuff // Continue throwing the notification base.OnSelectedValueChanged(sender, args); } }}
將音頻錄制到內(nèi)存流中,然后將其保存到文件中
慕無忌1623718
2021-06-22 17:13:02