DataGridView.OnCellContentClick(DataGridViewCellEventArgs) 方法

定義

引發 CellContentClick 事件。Raises the CellContentClick event.

protected:
 virtual void OnCellContentClick(System::Windows::Forms::DataGridViewCellEventArgs ^ e);
protected virtual void OnCellContentClick (System.Windows.Forms.DataGridViewCellEventArgs e);
abstract member OnCellContentClick : System.Windows.Forms.DataGridViewCellEventArgs -> unit
override this.OnCellContentClick : System.Windows.Forms.DataGridViewCellEventArgs -> unit
Protected Overridable Sub OnCellContentClick (e As DataGridViewCellEventArgs)

參數

e
DataGridViewCellEventArgs

DataGridViewCellEventArgs,其中包含內容被按一下之儲存格的相關資訊。A DataGridViewCellEventArgs that contains information regarding the cell whose content was clicked.

例外狀況

eColumnIndex 屬性值大於控制項中的資料行數目減一。The value of the ColumnIndex property of e is greater than the number of columns in the control minus one.

-或--or- eRowIndex 屬性值大於控制項中的資料列數目減一。The value of the RowIndex property of e is greater than the number of rows in the control minus one.

備註

引發事件會透過委派叫用此事件處理常式。Raising an event invokes the event handler through a delegate. 如需詳細資訊,請參閱處理和引發事件For more information, see Handling and Raising Events.

OnCellContentClick 方法也允許衍生類別處理事件,而不用附加委派。The OnCellContentClick method also allows derived classes to handle the event without attaching a delegate. 這是在衍生類別中處理事件的慣用技巧。This is the preferred technique for handling the event in a derived class.

給繼承者的注意事項

在衍生類別中覆寫 OnCellContentClick(DataGridViewCellEventArgs) 時,請務必呼叫基類 ' OnCellContentClick(DataGridViewCellEventArgs) 方法,讓已註冊的委派能接收事件。When overriding OnCellContentClick(DataGridViewCellEventArgs) in a derived class, be sure to call the base class' OnCellContentClick(DataGridViewCellEventArgs) method so that registered delegates receive the event.

適用於

另請參閱