/// <summary> /// Edits the Value of the given Object using the EditSyle given by GetEditStyle. /// </summary> /// <param name="context">An ITypeDescriptorContext, through wich you can get additional context information.</param> /// <param name="provider">An IServiceProvider, through which this editor may order services.</param> /// <param name="value">The Object to edit</param> /// <returns>The new value of the Object</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { ConnectionStringEditorForm eform; if(value != null && value.ToString() != String.Empty) { eform = new ConnectionStringEditorForm(value.ToString()); } else { eform = new ConnectionStringEditorForm(); } if(edSvc.ShowDialog(eform) == DialogResult.OK) { return eform.ConnectionString; } else { return value; } } else { return value; } } return value; }
private void button1_Click(object sender, System.EventArgs e) { ConnectionStringEditorForm Nnn = new ConnectionStringEditorForm(); Nnn.ShowDialog(); textBox1.Text = Nnn.ConnectionString.ToString(); }
/// <summary> /// Edits the Value of the given Object using the EditSyle given by GetEditStyle. /// </summary> /// <param name="context">An ITypeDescriptorContext, through wich you can get additional context information.</param> /// <param name="provider">An IServiceProvider, through which this editor may order services.</param> /// <param name="value">The Object to edit</param> /// <returns>The new value of the Object</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { ConnectionStringEditorForm eform; if (value != null && value.ToString() != String.Empty) { eform = new ConnectionStringEditorForm(value.ToString()); } else { eform = new ConnectionStringEditorForm(); } if (edSvc.ShowDialog(eform) == DialogResult.OK) { return(eform.ConnectionString); } else { return(value); } } else { return(value); } } return(value); }