简体   繁体   中英

How to automatically add data to a Bound DataGridView in C#

I have a form of a DataGridView that would take only one column entry from users, which is the Name column. The DateCreated (the second column) will be automatically entered by the system, so once a user want to enter a new name and presses enter, the DateCreated is automatically filled.

The data in the form is generated from a DataTable, and the DataTable content is in turn generated from a database. The thing is that the DateCreated columns is designed not to take null values, so when the DataSet was created the same constraint was enforced in the DataTable.

Can anyone please help with how to intercept the data in the DataGridView before it gets to the DataTable?

Thank you!

there are callback functions you can hook up to the dependency property. make a dependency property as data buffer, hook up validation module using those callback functions

http://msdn.microsoft.com/en-us/library/ms745795.aspx#Coerce_Value_Callbacks_and_Property_Changed_Events

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM