DataGridViewRowErrorTextNeededEventHandler DataGridViewRowErrorTextNeededEventHandler DataGridViewRowErrorTextNeededEventHandler DataGridViewRowErrorTextNeededEventHandler Delegate


表示将用来处理 RowErrorTextNeededDataGridView 事件的方法。Represents the method that will handle the RowErrorTextNeeded event of a DataGridView.

public delegate void DataGridViewRowErrorTextNeededEventHandler(System::Object ^ sender, DataGridViewRowErrorTextNeededEventArgs ^ e);
public delegate void DataGridViewRowErrorTextNeededEventHandler(object sender, DataGridViewRowErrorTextNeededEventArgs e);
type DataGridViewRowErrorTextNeededEventHandler = delegate of obj * DataGridViewRowErrorTextNeededEventArgs -> unit
Public Delegate Sub DataGridViewRowErrorTextNeededEventHandler(sender As Object, e As DataGridViewRowErrorTextNeededEventArgs)


Object Object Object Object

事件源。The source of the event.



RowErrorTextNeeded VirtualMode true当控件属性DataSource已设置或其属性为时, 才会发生此事件。 DataGridViewThe RowErrorTextNeeded event occurs only when the DataGridView control DataSource property is set or its VirtualMode property is true. 如果要根据行的状态和其包含的值确定行的错误, 则处理事件会很有用。RowErrorTextNeededHandling the RowErrorTextNeeded event is useful when you want to determine the error for a row depending on its state and the values it contains.

处理RowErrorTextNeeded事件并在处理程序中指定错误文本时, DataGridView.ShowRowErrors除非将属性设置为false, 否则行标题中将显示错误标志符号。When you handle the RowErrorTextNeeded event and specify error text in the handler, an error glyph appears in the row header unless the DataGridView.ShowRowErrors property is set to false. 当用户将鼠标指针移到错误标志符号上方时, 错误文本将显示在工具提示中。When the user moves the mouse pointer over the error glyph, the error text appears in a ToolTip.

如果RowErrorTextNeeded检索DataGridViewRow.ErrorText属性的值, 也会发生该事件。The RowErrorTextNeeded event also occurs whenever the value of the DataGridViewRow.ErrorText property is retrieved.

您可以使用DataGridViewRowErrorTextNeededEventArgs.RowIndex属性来确定行的状态或值, 并使用此信息来更改或DataGridViewRowErrorTextNeededEventArgs.ErrorText修改属性。You can use the DataGridViewRowErrorTextNeededEventArgs.RowIndex property to determine the state or value of a row, and use this information to change or modify the DataGridViewRowErrorTextNeededEventArgs.ErrorText property. 此属性将用行ErrorText属性的值进行初始化, 该属性的值将重写。This property is initialized with the value of the row ErrorText property, which the event value overrides.

处理大量数据时处理ErrorText 事件,以避免设置多行的行值时的性能损失。RowErrorTextNeededHandle the RowErrorTextNeeded event when working with large amounts of data to avoid the performance penalties of setting the row ErrorText value for multiple rows. 有关详细信息,请参阅 缩放 Windows 窗体 DataGridView 控件的最佳做法For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.

有关如何处理事件的详细信息, 请参阅处理和引发事件For more information about how to handle events, see Handling and Raising Events.

创建 DataGridViewRowErrorTextNeededEventHandler 委托时,需要标识将处理该事件的方法。When you create a DataGridViewRowErrorTextNeededEventHandler delegate, you identify the method that will handle the event. 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。To associate the event with your event handler, add an instance of the delegate to the event. 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。The event handler is called whenever the event occurs, unless you remove the delegate. 有关事件处理程序委托的详细信息, 请参阅处理和引发事件For more information about event-handler delegates, see Handling and Raising Events.


GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.