| 1. Close Visual Studio Exp. 2. Open the file MyObjectProps/My Object Properties.cs and add the public boolean property IsChecked to the end of the MyToolWindow class, just after the OnToolWindowCreated method SelectList(listObjects); } private bool isChecked = false; [Category("My Properties")] [Description("MyControl properties")] public bool IsChecked { get { return isChecked; } set { isChecked = value; control.checkBox1.Checked = value; } } 3. In the MyToolWindow constructor, add a this pointer to the MyControl construction: control = new MyControl(this); 4. Open the file MyControl.cs in code view. Replace the constructor with the following code: private MyToolWindow pane; public MyControl(MyToolWindow pane) { InitializeComponent(); this.pane = pane; } This gives MyControl access to the MyToolWindow object. 5. Change to design view. 6. Select the button and remove the anchors from the Anchor property. Shrink the button to a reasonable size in the lower left corner of the window. Drag a checkbox from the Toolbox to the upper left corner. 7. Double-click the checkbox. This creates the checkBox1_CheckedChanged event handler and opens it in the code editor. 8. Replace the checkbox event handler with the following code: private void checkBox1_CheckedChanged(object sender, EventArgs e) { pane.IsChecked = checkBox1.Checked; pane.UpdateSelection(); } 9. Make checkBox1 public: public CheckBox checkBox1; 10. Add this line to the MyControl constructor: InitializeComponent(); this.pane = pane; checkBox1.Checked = pane.IsChecked; 11. Build and launch the project in debug mode by pressing the keyboard shortcut, F5. This launches Visual Studio Exp. 12. From Visual Studio Exp, select the View/Other Windows menu item. Select the My Object Properties window. The window opens and the public properties of the window pane appear in the Property Browser. The IsChecked property appears under the category My Properties. 13. Select the IsChecked property. The description MyControl Properties appears. 14. Click on the checkbox in the My Object Properties window. IsChecked changes to True. Click it again to uncheck it. IsChecked changes to False. Change the value of IsChecked in the Property Browser. The checkbox in My Object Properties window changes to match the new value. Note If you need to dispose of a property or object displayed in the Property Browser, call OnSelectChange with a null selection container first. After disposing the property or object, you can change to a selection container with updated SelectableObjects and SelectedObjects lists. |