
Sharon Eden
Top achievements
Rank 1
Sharon Eden
asked on 06 May 2010, 03:17 PM
Hi,
I'm looking for a way to change the format of all the RadGridView instances in my application by default. Right now I would like to set the default font for the headers and rows and set the alignment. I have a method that is doing it and I'm using it for every RadGridView I'm creating, but I'm looking for something that will change all newly created grid view (just like the RadGridLocalizationProvider). I guess I can inherit the RadGridView and override some properties and event handler but is there a "built in" approach?
One more thing (please), Is there a way to set the column width as specified percentage of the table width?
Thanks,
Sharon.
I'm looking for a way to change the format of all the RadGridView instances in my application by default. Right now I would like to set the default font for the headers and rows and set the alignment. I have a method that is doing it and I'm using it for every RadGridView I'm creating, but I'm looking for something that will change all newly created grid view (just like the RadGridLocalizationProvider). I guess I can inherit the RadGridView and override some properties and event handler but is there a "built in" approach?
One more thing (please), Is there a way to set the column width as specified percentage of the table width?
Thanks,
Sharon.
7 Answers, 1 is accepted
0

Sharon Eden
Top achievements
Rank 1
answered on 12 May 2010, 07:29 AM
Any news about this one :-) ?
0
Hi Sharon Eden,
Thank you for the questions.
Yes, you can inherit RadGridView class and set the desired settings in your custom grid class. Please, consider the following code as example:
In regards to the build-in way, you can achieve your requirement by modifying the existing RadGridView ControlDefault theme. If you decide to follow this approach write, back and I will provide you with the necessary instructions.
As to your second question, RadGridView does not support setting column width as percentage, but you can easily implement such a scenario yourself by using SizeChanged event:
Let me know if you have any other questions.
Regards,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for the questions.
Yes, you can inherit RadGridView class and set the desired settings in your custom grid class. Please, consider the following code as example:
class
CustomGridView : RadGridView
{
Font _myFont =
new
Font(
"Ariel"
, 10, FontStyle.Regular);
public
CustomGridView() :
base
()
{
this
.GridElement.Font =
new
Font(_myFont, FontStyle.Bold);
this
.CellFormatting +=
new
CellFormattingEventHandler(CustomGridView_CellFormatting);
}
void
CustomGridView_CellFormatting(
object
sender, CellFormattingEventArgs e)
{
e.CellElement.Font = _myFont;
}
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadGridView).FullName;
}
}
}
In regards to the build-in way, you can achieve your requirement by modifying the existing RadGridView ControlDefault theme. If you decide to follow this approach write, back and I will provide you with the necessary instructions.
As to your second question, RadGridView does not support setting column width as percentage, but you can easily implement such a scenario yourself by using SizeChanged event:
void
radGridView1_SizeChanged(
object
sender, EventArgs e)
{
SetColumnSize();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
SetColumnSize();
}
void
SetColumnSize()
{
this
.radGridView1.Columns[0].Width =
this
.radGridView1.GridElement.Size.Width / 10;
}
Let me know if you have any other questions.
Regards,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Sharon Eden
Top achievements
Rank 1
answered on 12 May 2010, 09:42 AM
Hi Martin,
Thanks for your response.
I think I prefer to theme modification approach and I'll appreciate further assistance. By the way, I'm not using the default theme but rather the "Office2010" theme.
Thanks for the second answer too.
Sharon.
Thanks for your response.
I think I prefer to theme modification approach and I'll appreciate further assistance. By the way, I'm not using the default theme but rather the "Office2010" theme.
Thanks for the second answer too.
Sharon.
0
Accepted
Hi Sharon Eden,
Thank you for getting back to us.
In order to change the Font properties of RadGridView Office2010 theme, please follow these steps:
1. Open Visual Style Builder.
2. From the main menu choose File >> Export Build-in Themes. This option will export all predefined Telerik themes as theme packages.
3. From the main menu choose File >> Open Package and choose the Office2010.tssp package that you have just exported.
4. Set the Font property of the appropriate rows in the RadGridView control.
5. Save your package and then load it in your project as it is described here.
You can also refer to the following articles concerning the new Visual Style Builder:
http://www.telerik.com/help/winforms/vsb_overview.html
http://www.telerik.com/help/winforms/vsb_workingwithrepositoryitems.html
http://www.telerik.com/help/winforms/vsb_fontrepositoryitem.html
Please note, however, that you should set the TextAlignment preferences in code. It will be best if you create a RadGridView descendant and set the desired alignment there:
I hope this helps. If you have additional questions, feel free to contact me.
All the best,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for getting back to us.
In order to change the Font properties of RadGridView Office2010 theme, please follow these steps:
1. Open Visual Style Builder.
2. From the main menu choose File >> Export Build-in Themes. This option will export all predefined Telerik themes as theme packages.
3. From the main menu choose File >> Open Package and choose the Office2010.tssp package that you have just exported.
4. Set the Font property of the appropriate rows in the RadGridView control.
5. Save your package and then load it in your project as it is described here.
You can also refer to the following articles concerning the new Visual Style Builder:
http://www.telerik.com/help/winforms/vsb_overview.html
http://www.telerik.com/help/winforms/vsb_workingwithrepositoryitems.html
http://www.telerik.com/help/winforms/vsb_fontrepositoryitem.html
Please note, however, that you should set the TextAlignment preferences in code. It will be best if you create a RadGridView descendant and set the desired alignment there:
public
class
MyGridView : RadGridView
{
public
MyGridView()
{
this
.ViewCellFormatting +=
new
CellFormattingEventHandler(MyGridView_ViewCellFormatting);
}
void
MyGridView_ViewCellFormatting(
object
sender, CellFormattingEventArgs e)
{
if
(e.CellElement
is
GridHeaderCellElement)
{
e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
}
else
if
(e.CellElement
is
GridDataCellElement)
{
e.CellElement.TextAlignment = ContentAlignment.BottomLeft;
}
}
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadGridView).FullName;
}
}
}
I hope this helps. If you have additional questions, feel free to contact me.
All the best,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Sharon Eden
Top achievements
Rank 1
answered on 20 May 2010, 03:39 PM
Hi Nikolay,
It works perfectly.
Thanks,
Sharon.
It works perfectly.
Thanks,
Sharon.
0

Rasha Abdelhameed
Top achievements
Rank 1
answered on 12 Jul 2010, 02:39 PM
Hi,
I'm looking for a way to change the format of group panel and the text of it , also i wont to change the format of grid header
can any one help me in that
thanks,
Rasha.
I'm looking for a way to change the format of group panel and the text of it , also i wont to change the format of grid header
can any one help me in that
thanks,
Rasha.
0
Hi Rasha Abdelhameed,
If I have understood your question correctly, you want to modify the visual appearance of the group panel and the grid header parts. In this case you can use the Visual Style Builder tool. For additional information about it, please refer to the following support resources:
http://www.telerik.com/help/winforms/vsb_overview.html
http://www.telerik.com/help/winforms/vsb_workingwithrepositoryitems.html
http://www.telerik.com/help/winforms/vsb_propertyprecendence.html
http://www.telerik.com/help/winforms/styling_radribbonbar.html
Basically, you need to change the properties of GridTableHeaderRowElement/GridTableHeaderCellElement and GridGroupPanel. The latter can be accessed when RadGridView is in grouped preview mode. In order to apply this mode, right-click on the RadGridView control in the Controls Structure window and choose Show Grouping View.
If you have any specific questions during the process of modifying the visual appearance of RadGridView, feel free to contact me.
All the best,
Nikolay
the Telerik team
If I have understood your question correctly, you want to modify the visual appearance of the group panel and the grid header parts. In this case you can use the Visual Style Builder tool. For additional information about it, please refer to the following support resources:
http://www.telerik.com/help/winforms/vsb_overview.html
http://www.telerik.com/help/winforms/vsb_workingwithrepositoryitems.html
http://www.telerik.com/help/winforms/vsb_propertyprecendence.html
http://www.telerik.com/help/winforms/styling_radribbonbar.html
Basically, you need to change the properties of GridTableHeaderRowElement/GridTableHeaderCellElement and GridGroupPanel. The latter can be accessed when RadGridView is in grouped preview mode. In order to apply this mode, right-click on the RadGridView control in the Controls Structure window and choose Show Grouping View.
If you have any specific questions during the process of modifying the visual appearance of RadGridView, feel free to contact me.
All the best,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items