【MMC】Microsoft 管理コンソール ~プログラム作成 / プロパティ[3] ~


サンプル

ScopePropertiesControl.cs

UserControl/TextBox1
using System.Windows.Forms;
using Microsoft.ManagementConsole.Advanced;

/// <summary>
/// Gets the name and birthday.
/// </summary>
public partial class ScopePropertiesControl : UserControl
{
 /// <summary>
 /// Defines the parent property page to expose data and state of property sheet.
 /// </summary>
 private ScopePropertyPage scopePropertyPage;

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parentPropertyPage">Container property page for the control</param>
 public ScopePropertiesControl(ScopePropertyPage parentPropertyPage)
 {
  // This call is required by the Windows form designer.
  InitializeComponent();

  // Assign a reference to the parent.
  scopePropertyPage = parentPropertyPage;
 }
 /// <summary>
 /// Populate control values from the SelectionObject (that is set in UserListView.SelectionOnChanged).
 /// </summary>
 public void RefreshData(SampleScopeNode scopeNode)
 {
  this.textBox1.Text = scopeNode.DisplayName;
  scopePropertyPage.Dirty = false;
 }

 /// <summary>
 /// Update the node with the control values.
 /// </summary>
 /// <param name="scopeNode">Node being updated by property page</param>
 public void UpdateData(SampleScopeNode scopeNode)
 {
   scopeNode.DisplayName = this.textBox1.Text;
   scopePropertyPage.Dirty = false;
 }

 /// <summary>
 /// Checks during UserProptertyPage.OnApply to ensure that changes can be applied.
 /// </summary>
 /// <returns>returns true if changes are valid</returns>
 public bool CanApplyChanges()
 {
  bool result = false;

  if (textBox1.Text.Trim().Length == 0)
  {
    MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
    messageBoxParameters.Text = "Display Name cannot be blank";
    scopePropertyPage.ParentSheet.ShowDialog(messageBoxParameters);

    // MessageBox.Show("Display Name cannot be blank");
  }
  else
  {
      result = true;
     }
     return result;
 }

 /// <summary>
 /// Notifies the PropertyPage that info has changed and that the PropertySheet can change the 
 /// buttons
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void textBox1_TextChanged(object sender, System.EventArgs e)
 {
   scopePropertyPage.Dirty = true;
 }
}

書ききれいないので、以下に続く
http://blogs.yahoo.co.jp/dk521123/31647650.html