Using VS.NET PropertyGrid control
Using .NET Framework PropertyGrid control using System; using System.Drawing; using System.Collections;using System.ComponentModel;using System.Windows.Forms; using System
February 17, 2005
Using .NET Framework PropertyGrid
control using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Globalization;
[STAThread]
static void Main()
{
Application.Run(new OptionsDialog());
}
public class OptionsDialog : System.Windows.Forms.Form
{
private System.Windows.Forms.PropertyGrid OptionsPropertyGrid;
private AppSettings appset = new AppSettings();
public void GreetingsOnChange(string msg) {
this.Text=msg;
}
public OptionsDialog()
{
OptionsPropertyGrid = new PropertyGrid();
OptionsPropertyGrid.Size = new Size(300, 250);
appset.GreetingsOnChange += new GreetingsChanged(GreetingsOnChange );
this.Controls.Add(OptionsPropertyGrid);
this.Text = "Options Dialog";
// Create the AppSettings class and display it in the PropertyGrid.
OptionsPropertyGrid.SelectedObject = appset;
}
}
public delegate void GreetingsChanged(string msg);
public class AppSettings
{
private bool saveOnClose = true;
private string greetingText = "Welcome to your application!";
private int itemsInMRU = 4;
private int maxRepeatRate = 10;
private bool settingsChanged = false;
private string appVersion = "1.0";
private View view=View.Details;
private FormWindowState windowState=FormWindowState.Normal;
private Color toolbarColor = SystemColors.Control;
public event GreetingsChanged GreetingsOnChange;
public FormWindowState WindowState
{
get { return windowState; }
set { windowState= value;}
}
public View SaveView
{
get { return view; }
set { view= value;}
}
public Color ToolbarColor
{
get { return toolbarColor; }
set { toolbarColor = value; }
}
public bool SaveOnClose
{
get { return saveOnClose; }
set { saveOnClose = value;}
}
public string GreetingText
{
get { return greetingText; }
set { greetingText = value;
GreetingsOnChange(greetingText);
}
}
[ Description("This is repeate Rate")]
public int MaxRepeatRate
{
get { return maxRepeatRate; }
set { maxRepeatRate = value; }
}
public int ItemsInMRUList
{
get { return itemsInMRU; }
set { itemsInMRU = value; }
}
public bool SettingsChanged
{
get { return settingsChanged; }
set { settingsChanged = value; }
Read more about:
MicrosoftAbout the Author
You May Also Like