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

Can I change category name run time

2 Answers 68 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Hakan
Top achievements
Rank 1
Hakan asked on 10 Jun 2013, 07:13 PM
Hi ,
When I bind a object in propertygrid like a

PsPropertyGrid1.SelectedObject = MachineConfig
I want to change Category name at runtime for localization

I can change Item name and description with ItemFormatting event as fallow but Categoty property is readonly ,
How can I change category attirubute name at runtime in radpropertygrid... 

Private Sub PsPropertyGrid1_ItemFormatting(sender As Object, e As Telerik.WinControls.UI.PropertyGridItemFormattingEventArgs) Handles PsPropertyGrid1.ItemFormatting
            Select Case e.Item.Name
                Case Is = "MachineID"
                    'e.Item.Enabled = False
                    e.Item.Label = RM.GetString(7760)
                    e.Item.Description = RM.GetString(7761)

                Case Is = "CompanyInfo"
 .....
 .....

            End Select
Sub

Thanks for all helps...

2 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 13 Jun 2013, 04:43 PM
Hello Hakan,

Thank you for writing.

The best way to localize all the items displayed in the property grid is through the Label property. RadPropertyGird uses the label property to determine what text to display for an item. The Label property works the following way:
1. It checks whether there is a label set explicitly, if this is the case then it returns this label
2. It checks whether there is DisplayName attribute applied to the property, if this is true it returns the attribute value.
3. Returns the property name.
In the case of category items step two is skipped. So whenever you change the display language you can iterate over the items and assign the localized values.

I have attached a sample project where I have implemented an example localization using the Label property. Also to localize the UI elements of the property grid you can use a localization provider.

I hope this will be useful. Should you have further questions, I would be glad to help. 

Regards,
Ivan Petrov
Telerik
RadChart for WinForms is obsolete. Now what?
0
Hakan
Top achievements
Rank 1
answered on 13 Jun 2013, 05:03 PM
Thank you for your help Ivan. I solved my problem ...
Tags
PropertyGrid
Asked by
Hakan
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Hakan
Top achievements
Rank 1
Share this question
or