private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (this.dataGridView1.Rows[e.RowIndex].Cells["ID"].Value == null) { return; } int id = (int)this.dataGridView1.Rows[e.RowIndex].Cells["ID"].Value; //openMode == 0用于选择 if (openMode == 0) { string name = this.dataGridView1.Rows[e.RowIndex].Cells["name"].Value.ToString(); LookupArg lookupArg = new LookupArg(id, name); lookupArg.ArgName = conf.CategoryName; //File.AppendAllText("e:\\debug.txt", string.Format("double click, thread:{0}\r\n", System.Threading.Thread.CurrentThread.ManagedThreadId)); this.Close(); this.invokeLookupCallback(lookupArg); } else if (openMode == 1) { MyDockContent form = getItemForm(this, 1, id); form.updateNotify -= new UpdateNotify(form_updateNotify); form.updateNotify += new UpdateNotify(form_updateNotify); form.ShowDialog(); } }
/*************** general method *********************/ protected void appendEvent(MyDockContent form) { //发布更新,会在form里面的函数调用,每个form都新增这个事件处理函数 //比如customerUpdate更新,会让customerUpdate的版本加一 form.updateNotify += new MyDockContent.UpdateNotify(updateNotify); //界面等待 form.beginLoadNotify += new MyDockContent.BeginLoadNotify(beginLoadNotify); form.endLoadNotify += new MyDockContent.EndLoadNotify(endLoadNotify); }
private void toolStripButton_edit_Click(object sender, EventArgs e) { List <int> list = this.dataGridView1.getSelectIDs("ID", "check"); if (list == null || list.Count <= 0) { MessageBox.Show("请选择编辑" + conf.ItemName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MyDockContent form = getItemForm(this, 1, list[0]); form.updateNotify -= new UpdateNotify(form_updateNotify); form.updateNotify += new UpdateNotify(form_updateNotify); form.ShowDialog(); }
private void toolStripButton_add_Click(object sender, EventArgs e) { int parent; if (treeView1.SelectedNode != null) { parent = int.Parse(treeView1.SelectedNode.Name); } else { MessageBox.Show("请选择类别,如无类别请先增加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MyDockContent form = getItemForm(this, 0, 0); //这个地方可能还可以改进 form.updateNotify -= new UpdateNotify(form_updateNotify); form.updateNotify += new UpdateNotify(form_updateNotify); form.ShowDialog(); }