using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PTMedicalInsurance.FormSetter { class GridViewSetterBase { /// /// 动态增加datagridview列 /// /// /// /// protected void AddDGVColumn(DataGridView dgv, string headerText, string dataPropertyName, int width = 120) { DataGridViewColumn newColumn = new DataGridViewTextBoxColumn(); newColumn.HeaderText = headerText; newColumn.Width = width; newColumn.DataPropertyName = dataPropertyName; newColumn.Name = dataPropertyName; dgv.Columns.Add(newColumn); } } }