Cell borders disappear for GridViewCommandColumn

3 posts, 0 answers
  1. Per
    Per avatar
    2 posts
    Member since:
    Jan 2017

    Posted 11 Jan 2017 Link to this post

    Hi,

    I have a GridViewCommandColumn with buttons that are not always visible (using e.CellElement.Visibility = ElementVisibility.Hidden). When they are not visible the border lines around the cell disappear (see image 1).

    I tried to fix this using EnableCustomDrawing=True and subscribing to the CellPaint event and draw the border manually, but this does not seem to work. In fact the CellPaint event seem to happen BEFORE the buttons is drawn. I came to this conclusion by drawing a black border around all cells, and got the result in image 2.

    How can I fix this missing border problem?

    /Per

  2. Hristo
    Admin
    Hristo avatar
    1520 posts

    Posted 11 Jan 2017 Link to this post

    Hi Per,

    Thank you for writing.

    You can directly access the button element and set its Visibility property. A suitable place for performing this task is the handler of the CellFormatting event. Please check my code snippet below: 
    private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridCommandCellElement commandCell = e.CellElement as GridCommandCellElement;
        if (commandCell != null)
        {
            if (e.RowIndex % 2 == 0)
            {
                commandCell.CommandButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
            }
            else
            {
                commandCell.CommandButton.ResetValue(LightVisualElement.VisibilityProperty, Telerik.WinControls.ValueResetFlags.Local);
            }
             
        }
    }

    I am also sending you a screenshot showing the result on my end.

    I hope this helps. Please let me know if you need further assistance.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Per
    Per avatar
    2 posts
    Member since:
    Jan 2017

    Posted 11 Jan 2017 Link to this post

    Thank you!

    Calling ResetValue when the button is visible solved the problem...

    /Per

Back to Top