using CommonFroms.G2D.DataGrid; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace CommonFroms.G2D { public partial class G2DPropertyDialog : Form where T : class, new() { public G2DPropertyDialog(T data, params IG2DPropertyAdapter[] adds) { InitializeComponent(); if (data == null) { data = new T(); } this.g2DPropertyGrid1.SetSelectedObject(data, adds); this.g2DPropertyGrid1.Focus(); } public T SelectedObject { get { return this.g2DPropertyGrid1.GetSelectedValue() as T; } } //---------------------------------------------------------------------------------- public static T Show(string title, T data, params IG2DPropertyAdapter[] adds) { var dialog = new G2DPropertyDialog(data, adds); dialog.Text = title; DialogResult res = dialog.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { return dialog.SelectedObject; } return null; } } }