标题排序后,Datagridview动态按钮文本消失

时间:2014-08-21 15:37:34

标签: c# winforms datagridview

通过点击我的任何标题对数据网格视图进行排序时,我的按钮文字消失

var MoreInfoCol = new DataGridViewButtonColumn();
MoreInfoCol.Name = "MoreInfoColumn";
MoreInfoCol.HeaderText = "Extended Description";
dataGRID.Columns.Add(MoreInfoCol);

foreach (DataGridViewRow row in dataGRID.Rows)
{
row.Cells["MoreInfoColumn"].Value = row.Cells[2].Value.ToString() + " | More Info";
dataGRID.CellContentClick += new DataGridViewCellEventHandler(dataGRID_CellContentClick);                                        
}

1 个答案:

答案 0 :(得分:0)

我想通了

MoreInfoCol.UseColumnTextForButtonValue = true; 
MoreInfoCol.Text = "My Value Goes here";