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

BackColor Grid

4 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Konrad Radinger
Top achievements
Rank 1
Konrad Radinger asked on 06 Jul 2009, 04:20 AM
Hi,

I'm a beginner with the gridview. How can I change the backcolor of the grid?
radgridview1.backcolor = Color.Yellow doesn't work :-(

I found in the themebuilder the property: GridTableBodyElement. But I did find a snippet, how can I use it.

Greetings

Konrad

4 Answers, 1 is accepted

Sort by
0
Accepted
Boryana
Telerik team
answered on 06 Jul 2009, 12:55 PM
Hi Konrad Radinger,

Thank you for contacting us.

RadGridView is a complex control, which contains many other elements (for example RadButtonElement). Setting the BackColor property of radGridView does not work because this value is overridden in the control hierarchy. To achieve the desired result, you should set the background of each of its components.

Typically, there are four ways to customize the appearance of your radGridView. Please, have a look at this article.

In your case, you can handle CellFormatting or ViewCellFormating events. You can find more examples of using these events here. You second option is to create a custom theme, that sets the BackColor of the cells of the radGridView. Please, see how to modify themes in this tutorial. You can also see how to apply themes here.

I hope this is helpful. If you need any further assistance, do not hesitate to contact me back.

Kind regards,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Konrad Radinger
Top achievements
Rank 1
answered on 06 Jul 2009, 07:55 PM
Hi,

Ok, I have understand.

But I think, that's very complicate an not easy understandable. In the tree-control isn't that a problem. I set the backcolor and it works. In the grid-property I set the backcolor and it doesn't work :-(( 
I would only change the backcolor for the area where no rows. My grid starts with no rows. My customer can select a user-color. And that basic-thing isn't easy adjustable?

I hope I'm not too hard, otherwise I'm very happy with TELERIK :-)

Thank you

Konrad
0
Boryana
Telerik team
answered on 08 Jul 2009, 04:35 PM
Hello Konrad Radinger,

You are right that may be we should reconsider the BackColor property of the radGridView and its functionality for the future releases. Our team is grateful for your feedback. If you want to change the BackColor of the GridTableElement, you can use the following snippet:

this.radGridView1.GridElement.BackColor = Color.Yellow; 

This will change the BackColor of the whole GridTable area. Please, note that snippet will also affect the appearance of the rows since the default theme sets rows' BackColor to Transparent. That is why if you want to have rows' style unaffected by the GridTable BackColor, you should create a custom theme that sets the BackColor of the rows to non-transparent. If you encounter any issues creating your theme, please send us more information about the desired appearance of your RadGridView. Our team will be glad to assist you.

Greetings,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Konrad Radinger
Top achievements
Rank 1
answered on 08 Jul 2009, 09:26 PM
Hi,

thank you.
That works fine :-)

Greetings

Konrad
Tags
GridView
Asked by
Konrad Radinger
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Konrad Radinger
Top achievements
Rank 1
Share this question
or