Remove border around the GridView

6 posts, 1 answers
  1. Falk Wegener
    Falk Wegener avatar
    28 posts
    Member since:
    Oct 2007

    Posted 04 May 2011 Link to this post

    Dear Telerik team,

    is there a way to remove the border around the grid ?
    In our scenario the grid is nested inside a docking control, which comes with its own border.
    therefor we have two borders, which together look like a single thick border, breaking overall consistency.
    When opening the Visual UI Editor there is no Visual tree to change anything but the root element, so I guess all drawing
    is performed manually. Removing borders from the grids TableElement had no effect either. Any advide is greatly appreciated.

    Regards

    Falk Wegener
    orgAnice Software GmbH

  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 06 May 2011 Link to this post

    Hello Falk,

    To remove the border from the grid, you have to set the DrawBorder property of the GridViewElement & GroupPanelElement to false.

    this.radGridView1.GridViewElement.DrawBorder = false;
    this.radGridView1.GridViewElement.GroupPanelElement.DrawBorder = false;

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP

  3. Stefan
    Admin
    Stefan avatar
    2489 posts
    Member since:
    Sep 2012

    Posted 06 May 2011 Link to this post

    Hi Falk Wegener,

    Thank you for writing.

    Please refer to Emanuel's suggestion regarding removing the border of RadGridView and the group row (if such exists). 

    Additionally, I just want to add that if you do not have a group row, the header top borders will become top border of the grid. To remove them, subscribe to the ViewCellFormattingEvent and remove the top borders of the GridHeaderCellElement and GridTableHeaderCellElements:

          public Form1()
           {
               InitializeComponent();
               radGridView2.ViewCellFormatting += new Telerik.WinControls.UI.CellFormattingEventHandler(radGridView2_ViewCellFormatting);
           }
     
    void radGridView2_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
           {
               GridHeaderCellElement headerCell = e.CellElement as GridHeaderCellElement;
               if (headerCell != null)
               {
                   headerCell.BorderTopWidth = 0;
                    
               }
               GridTableHeaderCellElement headerIndentCell = e.CellElement as GridTableHeaderCellElement;
               if (headerIndentCell != null)
               {
                   headerIndentCell.BorderTopWidth = 0;
               }
           }

    I hope the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.

    Kind regards,
    Stefan
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.

  4. Falk Wegener
    Falk Wegener avatar
    28 posts
    Member since:
    Oct 2007

    Posted 06 May 2011 Link to this post

    Works perfectly, thank you both.

    Falk Wegener

  5. Silvia
    Silvia avatar
    7 posts
    Member since:
    Sep 2011

    Posted 07 Oct 2011 Link to this post

    Hi, I need to remove the border between rows i try with 

    this.radGridView1.GridViewElement.DrawBorder = false;
    this.radGridView1.GridViewElement.GroupPanelElement.DrawBorder = false;

    but GridViewElement is not accepted for the grid
     

  6. Stefan
    Admin
    Stefan avatar
    2489 posts
    Member since:
    Sep 2012

    Posted 11 Oct 2011 Link to this post

    Hi Silvia,

    Thank you for writing.

    You can remove the borders between the rows in RadGridView by setting the cells top and bottom border widths to 0. To introduce such a setting, you should make use of the ViewCellFormatting event of RadGridView. The following code snippet, demonstrates how to achieve such a look and also it keeps the top borders of RadGridView:

    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        //keep the top borders of the grid
        if (e.CellElement is GridHeaderCellElement || e.CellElement is GridTableHeaderCellElement || e.CellElement is GridHeaderIndentCellElement)
        {
            e.CellElement.BorderTopWidth = 1;
        }
        //remove all cells top and bottom borders
        else
        {
            e.CellElement.BorderTopWidth = 0;
            e.CellElement.BorderBottomWidth = 0;
        }
    }

    I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us. 

    All the best,
    Stefan
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top