public override void Refresh() { this._materialList = this.materialManager.Select(); this.bindingSource1.DataSource = this._materialList; if (this.action == "insert") { Model.Material mt = new Book.Model.Material(); mt.MaterialId = Guid.NewGuid().ToString(); this._materialList.Add(mt); this.bindingSource1.Position = this.bindingSource1.IndexOf(mt); this.gridControl1.RefreshDataSource(); } base.Refresh(); 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; } }
private void gridView1_KeyDown(object sender, KeyEventArgs e) { if (this.action != "view") { if (e.KeyData == Keys.Enter) { Model.Material material = new Book.Model.Material(); material.MaterialId = Guid.NewGuid().ToString(); this._materialList.Add(material); this.bindingSource1.Position = this.bindingSource1.IndexOf(material); } if (e.KeyData == Keys.Delete) { this.Delete(); } } this.gridControl1.RefreshDataSource(); }