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

Get the value represented by PropertyGridField

5 Answers 89 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Akram
Top achievements
Rank 1
Akram asked on 13 Dec 2012, 07:19 PM
Hi
Is there is a way to get the  value represented by PropertyGridField.

Thanks,
Akram

5 Answers, 1 is accepted

Sort by
0
Akram
Top achievements
Rank 1
answered on 14 Dec 2012, 03:42 PM
I found the solution by refection, 
there is an internal property called CurrentContextPropertyValue inside the field, call it by reflection and you will get the value associated to that field.

This is a sample code

var ss = typeof(PropertyGridField).GetProperty("CurrentContextPropertyValue", (BindingFlags)0xfff).GetValue(field,null);

Thanks,
Akram
0
Ivan Ivanov
Telerik team
answered on 14 Dec 2012, 04:09 PM
Hello,

Reflecting member that are not in the API is not a good practice. They are defined for internal use only and sometimes they might behave inconsistently in accordance to you expectations. 

Greetings,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Akram
Top achievements
Rank 1
answered on 14 Dec 2012, 04:10 PM
Ok, then please help me to find a safe way

Thanks,
Akram
0
Ivan Ivanov
Telerik team
answered on 14 Dec 2012, 04:18 PM
Hi,

Fields are ContentControls. You can get their content, cast it to the expected type (i.e TextBox) and retrieve the current value by reading the respective property (TextBox.Text).

Greetings,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Akram
Top achievements
Rank 1
answered on 14 Dec 2012, 07:23 PM
Hi
This can't be a perfect solution because i need the object to have the same reference to the origin one,
Also, Not all cases can be  cased into TextBox, some is DateTimePicker, some is Numeric .

Why not to provide a public property that do the same as the CurrentContextPropertyValue 

Thanks,
Akram
Tags
PropertyGrid
Asked by
Akram
Top achievements
Rank 1
Answers by
Akram
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or