C # Introduction to PropertyGrid instances

Source: Internet
Author: User

View plaincopy to clipboardprint?
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using System. IO;
Using System. Windows. Forms. Design;
Using System. Drawing. Design;
Namespace Quick. Dialog
{
Public partial class OptionsDlg: Form
{
OptionsInfo m_optInfo = new OptionsInfo ();
Public OptionsDlg ()
{
InitializeComponent ();
InitOptInfo ();
}
Private void InitOptInfo ()
{
LogicCommon comon = new LogicCommon ();
M_optInfo.ReportPath = comon. GetQualityKeys ("ReportPath ");
M_optInfo.ClientLocat = comon. GetQualityKeys ("ClientLocat ");
M_optInfo.InitDataList ();
}
Private void OptionsDlg_Load (object sender, EventArgs e)
{
PropertyGrid_optProp.SelectedObject = m_optInfo;
}
Private void propertyGrid_optProp_PropertyValueChanged (object s, PropertyValueChangedEventArgs e)
{
String strKey = e. ChangedItem. Label;
Object objValue = e. ChangedItem. Value;
M_optInfo.m_optDataList [strKey] = objValue. ToString ();
}
Private void button_ OK _Click (object sender, EventArgs e)
{
String strReportPath = m_optInfo.m_optDataList ["ReportPath"];
LogicCommon common = new LogicCommon ();
If (strReportPath = "")
{
MessageBox. Show ("the report file path cannot be blank! "," Error ", MessageBoxButtons. OK, MessageBoxIcon. Exclamation );
Return;
}
Try
{
Directory. CreateDirectory (strReportPath );
Common. SetQualityKeys ("ReportPath", strReportPath );
}
Catch (System. Exception err)
{
MessageBox. Show (err. Message, "invalid path ");
Return;
}
String strClientLocat = m_optInfo.m_optDataList ["ClientLocat"];
If (strClientLocat = "")
{
MessageBox. Show ("the client path cannot be blank! "," Error ", MessageBoxButtons. OK, MessageBoxIcon. Exclamation );
Return;
}
Common. SetQualityKeys ("ClientLocat", strClientLocat );
This. DialogResult = DialogResult. OK;
}
Private void button_cancel_Click (object sender, EventArgs e)
{
}
}
Public class PathEditor: UITypeEditor
{
Public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
{
If (context! = Null & context. Instance! = Null)
{
Return UITypeEditorEditStyle. Modal;
}
Return base. GetEditStyle (context );
}
Public override object EditValue (ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService editorService = null;
If (context! = Null & context. Instance! = Null & provider! = Null)
{
EditorService = (IWindowsFormsEditorService) provider. GetService (typeof (IWindowsFormsEditorService ));
If (editorService! = Null)
{
FolderBrowserDialog dirDlg = new FolderBrowserDialog ();

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.