This question is locked. New answers and comments are not allowed.
Hi,
I am trying to set the color and thickness of the row.
Here is my code
private void SetSolidBorder(GridViewRow Row, Color BorderColor, int BorderThickness)
{
try
{
Row.BorderBrush = new SolidColorBrush(BorderColor);
Row.BorderThickness = new Thickness(BorderThickness);
}
catch (Exception ex)
{
throw ex;
}
}
and i am calling it like
GridViewRow row= this.ItemContainerGenerator.ContainerFromItem(this.CurrentItem) as GridViewRow;
SetSolidBorder(Row, Colors.Purple , 10);
But it is setting neither color nor thickness.
Rgds
Alfa
5 Answers, 1 is accepted
0
Hello Alfa,
You can change the border thickness and the brush by directly accessing the visual element using the following code:
Alternatively if you want to change all rows' border you can use the custom row template for the gridview.
Let me now if this works for you.
Kind regards,
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can change the border thickness and the brush by directly accessing the visual element using the following code:
Border rowBorder = Row.ChildrenOfType<Border>().Where(c => c.Name == "PART_RowBorder").First();Alternatively if you want to change all rows' border you can use the custom row template for the gridview.
Let me now if this works for you.
Kind regards,
Tsvyatko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Alfa
Top achievements
Rank 1
answered on 01 Dec 2009, 11:52 AM
Hi,
Thank you.
The code it working but one issue.
It is changing the border of the "RowIndicator" column too.
Along with that is there any way of restore the original border.
Actually, I am using border to show the error and want to restore the original border if the error is rectified.
Rgds
Alfa
0
Accepted
Hello Alfa,
In your case you can take advantage of another visual element in the row designed specially for validation.
It can be acquired using the following code:
It is displayed when trying to add invalid value in a cell. If it need to be shown manually by setting rectangle opacity to 1.
Additionally you can customize the grid row style or just control the visual elements from code behind.
I am attaching sample project illustrating the solution.
If you have any more questions do not hesitate to contact us.
Regards,
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
In your case you can take advantage of another visual element in the row designed specially for validation.
It can be acquired using the following code:
Rectangle rect = e.Row.ChildrenOfType<Rectangle>().Where(c => c.Name == "InvalidBorder").First() as Rectangle;It is displayed when trying to add invalid value in a cell. If it need to be shown manually by setting rectangle opacity to 1.
Additionally you can customize the grid row style or just control the visual elements from code behind.
I am attaching sample project illustrating the solution.
If you have any more questions do not hesitate to contact us.
Regards,
Tsvyatko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Alfa
Top achievements
Rank 1
answered on 07 Dec 2009, 07:50 AM
Hi,
Is this visual element is available for cell too?
Rgds
Alfa
0
Hi Alfa,
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The element you are looking for is accessed using the following code:
Border border= e.Cell.ChildrenOfType<Border>().Where(c => c.Name == "ValidationErrorElement").First() as Border;Keep in mind that this element can be accessed only in cell edit mode.
However there is alternative solution - you can use CellValidating event to validate the cell content before committing it. Check this demo for reference.
If these solutions does not fulfill you requirements you can define your own CellTemplate adding border elements of your taste.
I hope this helps.
Regards,Tsvyatko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.