private string SetDocSettings(string initText) { string text = initText; DialogHostFormPC dialogHostForm = new DialogHostFormPC("", 600, 300); Panel panel = new Panel(); Panel panel1 = new Panel(); DataGridView grid = new DataGridView(); dialogHostForm.Child = panel; grid.Columns.Add("Caption", "标题"); grid.Columns.Add("Key", "键名"); grid.Columns.Add("Path", "文件"); grid.Columns.Add("Type", "类全名"); grid.Columns[2].Width = 200; List <string> list = new List <string>(); if (!string.IsNullOrEmpty(text)) { list = new List <string>(text.Split(',')); } if (list.Count > 4) { list[3] = list[3] + "," + list[4]; list.RemoveRange(4, list.Count - 4); } while (list.Count < 4) { list.Add(""); } grid.Rows.Add(list.ToArray()); grid.Columns[1].ReadOnly = true; grid.Columns[2].ReadOnly = true; grid.Columns[3].ReadOnly = true; grid.RowHeadersVisible = false; grid.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; grid.AllowUserToAddRows = false; grid.AllowUserToDeleteRows = false; grid.CellDoubleClick += new DataGridViewCellEventHandler(grid_CellDoubleClick); MedButton btn1 = new MedButton(); btn1.Text = "确定"; btn1.DialogResult = DialogResult.OK; MedButton btn2 = new MedButton(); btn2.Text = "取消"; btn2.DialogResult = DialogResult.Cancel; panel.Controls.Add(grid); panel.Controls.Add(panel1); panel1.Height = 50; panel1.Dock = DockStyle.Bottom; grid.Dock = DockStyle.Fill; panel1.Controls.Add(btn1); panel1.Controls.Add(btn2); btn1.Left = 10; btn1.Top = 5; btn2.Top = 5; btn2.Left = 100; if (dialogHostForm.ShowDialog() == DialogResult.OK) { text = grid.Rows[0].Cells[0].Value + "," + grid.Rows[0].Cells[1].Value + "," + grid.Rows[0].Cells[2].Value + "," + grid.Rows[0].Cells[3].Value; } return(text); }
protected override Control GetEditControl(object instance) { _source = instance; if (_source != null) { _panelBody = new Panel(); _panelBody.Width = 800; _panelBody.Height = 500; Panel panelBottom = new Panel(); panelBottom.Height = 80; panelBottom.Dock = DockStyle.Bottom; _panelBody.Controls.Add(panelBottom); MedButton btnUp = new MedButton(); btnUp.Click += new EventHandler(btnUp_Click); panelBottom.Controls.Add(btnUp); btnUp.Text = "上移(&W)"; btnUp.Location = new System.Drawing.Point(10, 10); btnUp.Width = 60; MedButton btnDown = new MedButton(); btnDown.Click += new EventHandler(btnDown_Click); panelBottom.Controls.Add(btnDown); btnDown.Text = "下移(&S)"; btnDown.Location = new System.Drawing.Point(90, 10); btnDown.Width = 60; MedButton btnAdd = new MedButton(); btnAdd.Click += new EventHandler(btnAdd_Click); panelBottom.Controls.Add(btnAdd); btnAdd.Text = "添加(&A)"; btnAdd.Location = new System.Drawing.Point(170, 10); btnAdd.Width = 60; MedButton btnDelete = new MedButton(); btnDelete.Click += new EventHandler(btnDelete_Click); panelBottom.Controls.Add(btnDelete); btnDelete.Text = "删除(&D)"; btnDelete.Location = new System.Drawing.Point(250, 10); btnDelete.Width = 60; MedButton btnOK = new MedButton(); btnOK.Click += new EventHandler(btnOK_Click); panelBottom.Controls.Add(btnOK); btnOK.Text = "确定(&O)"; btnOK.Location = new System.Drawing.Point(410, 10); btnOK.Width = 60; _gird = new MedGridView(); _gird.Columns.Add("显示文本", "显示文本"); _gird.Columns.Add("字段名称", "字段名称"); _gird.Columns.Add("宽度", "宽度"); _listBox = new ListBox(); _propertyGrid = new PropertyGrid(); if (_source is MedGridView) { (_source as MedGridView).GetMedGridViewColumns(out _medGridViewColumns); } //else // if (_source is MedDevGrid) // { // (_source as MedDevGrid).GetMedGridViewColumns(out _medGridViewColumns); // } ResetList(); _panelBody.Controls.Add(_gird); _gird.Dock = DockStyle.Left; _gird.BringToFront(); _gird.Visible = false; _panelBody.Controls.Add(_listBox); _listBox.Dock = DockStyle.Left; _listBox.BringToFront(); _listBox.Width += 30; _listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged); _panelBody.Controls.Add(_propertyGrid); _propertyGrid.Dock = DockStyle.Fill; _propertyGrid.BringToFront(); _propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged); return(_panelBody); } else { return(base.GetEditControl(instance)); } }