C#BindingNavigator.添加新按钮和LINQ [英] C# BindingNavigator. Add New Button & LINQ
问题描述
在绑定导航器上单击添加新按钮时,它将在datagridview中创建一个空行,等待用户输入数据.我想在创建时访问该对象并为其提供默认值.
When you click on the add new button on the bindingnavigator it will create an empty row in a datagridview, waiting for the user to enter data. I would like to access this object on creation and give it default values.
这可能吗?
Is this possible?
推荐答案
在列表控件中进行编辑是一个坏主意,常见的设计是弹出一个为CRUD操作设计的对话框,检测对话框结果并从数据库中重新加载列表.
Editing in a list control is a bad idea, a common design is to pop a dialog designed for the CRUD operations, detect the dialogresult and reload the list from the database.
不过,您可以使用默认值加载新的数据记录,在按钮click事件中处理基础数据容器(datatable,List<>)来添加记录和默认值.
However you can load your new data record with defaults, in the button click event deal with the underlying data container (datatable, List<>) to add the record and defaults.
这篇关于C#BindingNavigator.添加新按钮和LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!