DataGridViewRowErrorTextNeededEventHandler 委托

定义

表示将用来处理 RowErrorTextNeededDataGridView 事件的方法。

public delegate void DataGridViewRowErrorTextNeededEventHandler(System::Object ^ sender, DataGridViewRowErrorTextNeededEventArgs ^ e);
public delegate void DataGridViewRowErrorTextNeededEventHandler(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)

参数

sender
Object

事件源。

注解

RowErrorTextNeeded仅当控件属性已设置或其VirtualMode属性为 trueDataGridViewDataSource,才会发生该事件。 RowErrorTextNeeded若要根据行的状态及其包含的值来确定行的错误时,处理事件非常有用。

处理 RowErrorTextNeeded 事件并在处理程序中指定错误文本时,行标题中会显示错误字形, DataGridView.ShowRowErrors 除非 属性设置为 false。 当用户将鼠标指针移到错误字形上时,错误文本将显示在工具提示中。

每当 RowErrorTextNeeded 检索属性的值时, DataGridViewRow.ErrorText 也会发生 该事件。

可以使用 DataGridViewRowErrorTextNeededEventArgs.RowIndex 属性来确定行的状态或值,并使用此信息来更改或修改属性 DataGridViewRowErrorTextNeededEventArgs.ErrorText 。 此属性使用事件值替代的行 ErrorText 属性的值进行初始化。

RowErrorTextNeeded处理大量数据时处理 事件,以避免为多行设置行ErrorText值而造成性能损失。 有关详细信息,请参阅 缩放 Windows 窗体 DataGridView 控件的最佳做法

有关如何处理事件的详细信息,请参阅 处理和引发事件

创建 DataGridViewRowErrorTextNeededEventHandler 委托时,需要标识将处理该事件的方法。 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。 有关事件处理程序委托的详细信息,请参阅 处理和引发事件

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于

另请参阅