public override void Refresh() { this._detail = this.outgoingKindManager.Select(); this.bindingSource1.DataSource = this._detail; if (this.action == "insert") { Model.OutgoingKind ok = new Book.Model.OutgoingKind(); ok.OutgoingKindId = Guid.NewGuid().ToString(); this._detail.Add(ok); // this.bindingSource1.DataSource = this._detail; this.bindingSource1.Position = this.bindingSource1.IndexOf(ok); this.gridControl1.RefreshDataSource(); } switch (this.action) { case "insert": this.gridView1.OptionsBehavior.Editable = true; break; case "update": this.gridView1.OptionsBehavior.Editable = true; break; case "view": this.gridView1.OptionsBehavior.Editable = false; break; default: break; } base.Refresh(); }
private void gridView1_KeyDown(object sender, KeyEventArgs e) { if (this.action == "insert" || this.action == "update") { if (e.KeyData == Keys.Enter) { Model.OutgoingKind ok = new Book.Model.OutgoingKind(); ok.OutgoingKindId = Guid.NewGuid().ToString(); this._detail.Add(ok); this.bindingSource1.Position = this.bindingSource1.IndexOf(ok); } if (e.KeyData == Keys.Delete) { this._detail.Remove(this.bindingSource1.Current as Model.OutgoingKind); } this.gridControl1.RefreshDataSource(); } }