C# Telerik radgridview单元格格式不稳定
我有一个包含许多列的radgridview(水平滚动条已激活)。C# Telerik radgridview单元格格式不稳定,c#,winforms,telerik,radgridview,C#,Winforms,Telerik,Radgridview,我有一个包含许多列的radgridview(水平滚动条已激活)。 我的网格中有一个CommandColumn&我想将其格式化如下: private void rad_grd_Requests_CellFormatting(object sender, CellFormattingEventArgs e) { if (e.CellElement.ColumnInfo is GridViewCommandColumn) { RadBut
我的网格中有一个CommandColumn&我想将其格式化如下:
private void rad_grd_Requests_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement.ColumnInfo is GridViewCommandColumn)
{
RadButtonElement button = (RadButtonElement)e.CellElement.Children[0];
if (e.CellElement.RowInfo.Cells["Admin_Action"].Value.ToString() == "Hold")
{
button.Text = "Done";
}
else
{
button.Text = "Done";
button.Visibility = ElementVisibility.Hidden;
}
}
}
程序启动时,一切正常。但当我使用网格的水平滚动条时,CommandColumn中的所有按钮有时都不可见。(多次运行CellFormatting())
为什么CellFormatting()不稳定&如何解决此问题 由于RadGridView中的UI虚拟化,单元格元素仅为当前可见的单元格创建,并在滚动、筛选、分组等操作期间重复使用。为了防止将格式应用于其他列的单元元素(因为单元重用),应重置其余单元元素的所有自定义 请参阅以下帮助文章,演示如何正确自定义单元格和重置样式: 我希望这些信息有帮助 答案如下:
RadButtonElement button = (RadButtonElement)e.CellElement.Children[0];
if (e.CellElement.RowInfo.Cells["Admin_Action"].Value.ToString() == "Hold")
{
button.Text = "Done";
button.Visibility = ElementVisibility.Visible;
}
else
{
button.Text = "Done";
button.Visibility = ElementVisibility.Hidden;
}
添加button.Visibility=ElementVisibility.Visible代码>向您发送代码