[英]Winform C# : Set default value to particular column in datagrid
Winform C#:
我在dataGrid中有3列,例如ID,Name,Date。 我必須在按鈕單擊事件的每一行上為“日期”列設置特定的值。
我嘗試使用datagrid的Default屬性,但是當新行添加到datagrid時它將設置默認值。
謝謝。
foreach(DataGridViewRow Row in myGrid.Rows)
{
Row.Cells[2].Value = DateTime.Now; // Sets the value of the third column
}
你的意思是這樣嗎? 這將遍歷數據網格中的所有行,並將第三列的值設置為當前日期/時間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.