I have a radgridview with many columns (Horizontal Scroll Bar has been activated).
I have a CommandColumn in my grid & i want to format it like this :
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;
}
}
}
When program starts every thing is ok.
But when i use horizontal scroll bar of grid some times all buttons in CommandColumn be invisible.(Multiple run of CellFormatting())
Why CellFormatting() is not stable & how can i fix this problem?
Here is the answer :
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;
}
Add button.Visibility = ElementVisibility.Visible;
to you codes.