public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { string oldvalue = (context.Instance as TagItem).Exp; IOfficePlate op = (context.Instance as TagItem).Collection.Owner as IOfficePlate; List<IComponent> listcomponent = new List<IComponent>(); if (op is OfficePlate) { IContainer container = (op as OfficePlate).Container; for (int i = 0; i < container.Components.Count; i++) { if (container.Components[i] is Control) { listcomponent.Add(container.Components[i]); } } } else { System.Web.UI.Page page = (op as WebOfficePlate).Page; for (int i = 0; i < page.Controls.Count; i++) { listcomponent.Add(page.Controls[i]); } WebExcelPlate newplate = new WebExcelPlate(); foreach (WebDataSourceItem item in (op as WebOfficePlate).WebDataSource) { newplate.WebDataSource.Add(item); } page.Controls.Add(newplate);//avoid null page exception, modified on 2007/9/11 newplate.InitialDataSourceItem(); op = newplate; } frmValue fv = new frmValue(oldvalue, op, listcomponent); if (fv.ShowDialog() == DialogResult.OK) { value = fv.tbScript.Text.Replace("\r", string.Empty).Replace("\n", string.Empty); } if (op is WebOfficePlate) { (op as WebOfficePlate).Page.Controls.Remove(op as WebOfficePlate);//remove the control in page avoid problem } } return value; }
private void dataGridViewTag_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { if (dataGridViewTag.Columns[e.ColumnIndex].Name == "ColumnExpression") { object strexpression = dataGridViewTag.Rows[e.RowIndex].Cells["ColumnExpression"].Value; if (strexpression == null) { strexpression = string.Empty; } List<IComponent> listcomponent = new List<IComponent>(); for (int i = 0; i < DesignerHost.Container.Components.Count; i++) { if (DesignerHost.Container.Components[i] is Control) { listcomponent.Add(DesignerHost.Container.Components[i]); } } frmValue fv = new frmValue(strexpression.ToString(), plate, listcomponent); if (fv.ShowDialog() == DialogResult.OK) { dataGridViewTag.Rows[e.RowIndex].Cells["ColumnExpression"].Value = fv.tbScript.Text.Replace("\r", string.Empty).Replace("\n", string.Empty); tabPageTag.Text = "Tag Defination*"; btnSaveTag.Enabled = true; btnUndoTag.Enabled = true; } e.Cancel = true; } else { tabPageTag.Text = "Tag Defination*"; btnSaveTag.Enabled = true; btnUndoTag.Enabled = true; } }