private void simpleButton1_Click(object sender, EventArgs e) { if (textEdit1.Text == "") { MessageBox.Show("名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } UseGroup ug = new UseGroup(); ug.UID = Guid.NewGuid().ToString(); ug.GroupName = textEdit1.Text; ug.Content = content; ug.Remark = textEdit2.Text; ug.X = rect.X.ToString(); ug.Y = rect.Y.ToString(); ug.Width = rect.Width.ToString(); ug.Height = rect.Height.ToString(); Services.BaseService.Create <UseGroup>(ug); this.Close(); }
/// <summary> /// 删除焦点对象 /// </summary> public void DeleteObject() { //获取焦点对象 UseGroup obj = FocusedObject; if (obj == null) { return; } //请求确认 if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { return; } //执行删除操作 try { Services.BaseService.Delete <UseGroup>(obj); } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return; } this.gridView.BeginUpdate(); //记住当前焦点行索引 int iOldHandle = this.gridView.FocusedRowHandle; //从链表中删除 ObjectList.Remove(obj); //刷新表格 gridControl.RefreshDataSource(); //设置新的焦点行索引 GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle); this.gridView.EndUpdate(); }
private void gridControl_DoubleClick(object sender, EventArgs e) { Object = FocusedObject; }