DataGridView显示、更新数据

添加一行数据:

/// <summary> /// 添加一条新记录到DataGridView中 /// </summary> /// <param name="dataTable"></param> /// <param name="info"></param> private void AddNewRow(ref DataTable dataTable,LimitInfo info) { DataRow dataRow = dataTable.NewRow(); dataRow["Mac"] = info.Mac; dataRow["Name"] = info.Name; dataRow["IsKillProcess"] = info.IsKillProcess; dataRow["IsUse"] = info.IsUse; dataRow["Type"] = info.Type; dataTable.Rows.Add(dataRow); }

 

更新一行数据:

dataGridView_LimitList.SelectedRows[0].Cells["Name"].Value = operateForm.IllegalName; dataGridView_LimitList.SelectedRows[0].Cells["IsKillProcess"].Value = operateForm.IsKillProcess; dataGridView_LimitList.SelectedRows[0].Cells["IsUse"].Value = operateForm.IsUse;

 

删除一行数据:

dataGridView_LimitList.Rows.Remove(dataGridView_LimitList.CurrentRow);

你可能感兴趣的:(DataGridView显示、更新数据)