This is a migrated thread and some comments may be shown as answers.

Gridline in gridview

1 Answer 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 02 Nov 2011, 07:30 PM
Hello,
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

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 07 Nov 2011, 10:03 AM
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.

Greetings,
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.

Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or