What is the correct way to show the selected object of a property Grid?
In Visual Studio they use a combobox. Is there a default setting that I can change to enable this or something like it?
Short Video Explanation: http://youtu.be/uI5crr_9hZA
In Visual Studio, the Properties
windows is actually a pane having ComboBox
and PropertyGrid
controls (checked with UISpy
tool).
If you want to have similar functionality, you could add a ToolStripComboBox
to the PropertyGrid
toolbar using its controls collection. Add the object collection to this combo and in the SelectedIndexChanged
handler set the SelectedObject
of PropertyGrid
to the selected item in the combo.
Sample code:
ToolStripComboBox objectDropDown = new ToolStripComboBox();
foreach (Control item in propertyGrid1.Controls)
{
ToolStrip toolstrip = item as ToolStrip;
if (toolstrip != null)
{
toolstrip.Items.Add(objectDropDown);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.