设置绑定DGV的数据的默认值

问题描述:

嘿。



我从这开始我是C#和WinForms的新手所以如果需要请像对待白痴一样对待我尽可能简单地解释事情:)。



所以..最近我开始了一个新项目,它包含绑定到SQL Server Table的DGV。当用户添加新行时,我想在他向DB创建新行时传递有关他的登录和日期的信息。



我在表格中创建了2列 - UsrCrt和DtCrt。我已经发现要通过创建日期我应该只是DateTime.Now,对于Windows用户我应该使用System.Security.Principal.WindowsIdentity.GetCurrent()。名称。



但是,我真的不知道如何将这些作为DGV新行的默认值。

Hey.

I'd start with this that I'm pretty new to C# and WinForms so if needed please treat me like an idiot if it's necessary to explain things the easiest way possible :).

So.. Recently I started a new project, it contains DGV which is binded to SQL Server Table. When user adds new row I'd like to pass information about his login and date when he created new row into DB.

I created in my table 2 columns - UsrCrt and DtCrt. I already found out that to pass the creation date I should simply just DateTime.Now, and for Windows user I should use System.Security.Principal.WindowsIdentity.GetCurrent().Name .

However, I don't really have an idea how should I put those as default values for DGV new row.

当你创建新的时候行,将数据添加到该行的列中。
When you creat the new row, add data into the columns of that row.