Gridline in gridview

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Oct 2011

    Posted 02 Nov 2011 Link to this post

    I have used the desert theme as my form theme and aqua for my gridview. There are two problems which i have faced during working with this themes. i will be appreciate if you help me with these issues.
    1. After finalizing the gridview, the gridlines can not be viewed and the rows can only be distinguished by different colours. how can i apply these gridlines? 
    2. In the gridview which is seen in run-time, the numbers are placed in the left side of the column and the strings are placed on the right side of the column. is there a way to arrange both of them in the same direction, let's say both in right or left side?

    thanks in advance
    David Namer
  2. Ivan Petrov
    Ivan Petrov avatar
    715 posts

    Posted 07 Nov 2011 Link to this post

    Hi David,

    Thank you for writing.

    In regards to your first question. There are several ways to make the different rows distinguishable. You can enable the alternating row colors by setting the RadGridView EnableAlternatingRowColor to true. You can also use the CellFormatting event to set the borders of the cells. Consider the following code snippet which draws only the top and bottom borders of the cells:

    private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
      e.CellElement.DrawBorder = true;
      e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
      e.CellElement.BorderLeftWidth = 0;
      e.CellElement.BorderRightWidth = 0;
      e.CellElement.BorderTopColor = Color.LightBlue;
      e.CellElement.BorderBottomColor = Color.LightBlue;

     If this does not cover your requirements, I would kindly ask you to provide some more details on what you want tot achieve. If you can attach a screen shot or a drawing of what you want you will help me better understand your goal.

    As to your second question, you can set the text alignment directly to the RadGridView columns. Here is a code snippet which demonstrates how to set it for all grid columns:
    foreach (GridViewDataColumn column in this.radGridView1.Columns)
      column.TextAlignment = ContentAlignment.MiddleCenter;
    I hope this will be useful for you. If you have further questions, I would be glad to help.

    Ivan Petrov
    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