【发布时间】:2011-11-09 07:32:11
【问题描述】:
是否可以使用扩展方法来扩展索引器?我希望能够使用这样的标题文本从给定DataGridViewRow 的DataGridViewCell 中获取单元格的值:
object o = row["HeaderText"];
我有这个代码
public static class Ext
{
public static object Cells(this DataGridViewRow r, string header)
{
foreach (DataGridViewCell c in r.Cells)
{
if (c.OwningColumn.HeaderText == header)
{
return c.Value;
}
}
return null;
}
}
我想要类似的索引器。谢谢。
【问题讨论】:
标签: c# datagridview indexer