and the current view from the grid will be set to the default view. for example (all open properties will be closed)
the WindowsForm PropertyGrid do this not!
how can i change this behavior?
BR
Sebastian
5 Answers, 1 is accepted
Thank you for writing.
We will consider implementing this scenario in one of our future releases if there is growing demand for this feature. For now you can use the following workaround method to set the RadPropertyGrid SlectedObject:
private
void
SetNewSelectedObject(
object
newSelectedObject)
{
string
propertyName = String.Empty;
int
scrollValue = 0;
bool
sameType =
false
;
if
(
this
.radPropertyGrid1.SelectedObject !=
null
&&
this
.radPropertyGrid1.SelectedGridItem !=
null
)
{
sameType =
this
.radPropertyGrid1.SelectedObject.GetType() == newSelectedObject.GetType();
propertyName =
this
.radPropertyGrid1.SelectedGridItem.Name;
if
(sameType)
{
scrollValue =
this
.radPropertyGrid1.PropertyGridElement.PropertyTableElement.VScrollBar.Value;
}
}
this
.radPropertyGrid1.SelectedObject = newSelectedObject;
this
.radPropertyGrid1.SelectedGridItem =
this
.radPropertyGrid1.Items[propertyName];
if
(
this
.radPropertyGrid1.SelectedGridItem !=
null
)
{
if
(sameType)
{
this
.radPropertyGrid1.PropertyGridElement.PropertyTableElement.VScrollBar.Value = scrollValue;
}
else
{
this
.radPropertyGrid1.SelectedGridItem.EnsureVisible();
}
}
}
I hope this will help you. Should you need further assistance, I would be glad to provide it.
Kind regards,
Ivan Petrov
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
thanks for your reply but this will be only work for the scolling postion.
what i need is the postition/state of the opening collections . this is very disturb when all open collections closed after ...selectedobject
for example see the picture in the attachment
thanks for your help
BR
Sebastian
Thank you for your reply and for the attached screen shot.
I understand your demand and I have prepared a sample project which extends my previous post. In the solution you will find a form with a property grid and two buttons clicking on the buttons will set them as the selected object of the property grid and will preserve the visual state of the property grid.
I hope you will find this helpful. If there is anything else I can help with, I would be glad to do so.
Ivan Petrov
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
yes thank you very much, this is it what i'm looking for.
i have found a little error in this code, when you don't expand an collection and select a new object then you get a null exception.
when you check this before then is the code perfect (i have fix this for me)
it is possible to set this code as default or as an option in the next version of the propertygrid ?
thanks for the great support.
BR
Sebastian
Thank you for writing back.
I am glad we have found a way through this. Now that we have the code it will be easier to include it in the actual RadPropertyGrid. We will consider this feature when we plan our future releases.
If you have other questions feel free to write again.
Ivan Petrov
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.