如何检查DataGridTextColumn绑定到哪个DataColumn

本文关键字:绑定 DataColumn DataGridTextColumn 何检查 检查 | 更新日期: 2023-09-27 18:00:44

我想检查DataGridTextColumn绑定到哪个DataColumn

我正在尝试做一些类似的事情:

private void kblMeoravPrDataGrid_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
{
     if ((e.Column as DataGridTextColumn).Binding.Path == "DBFieldName")
     {

如何检查DataGridTextColumn绑定到哪个DataColumn

您应该首先检查该值是否为null。

var dataGridTextColumn = e.Column as DataGridTextColumn;
if (dataGridTextColumn != null) // If not null then the column is DataGridTextColumn
{
   //working
}