12345678910111213141516171819202122232425262728 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PTMedicalInsurance.FormSetter
- {
- public class GridViewSetterBase
- {
- /// <summary>
- /// 动态增加datagridview列
- /// </summary>
- /// <param name="dgv"></param>
- /// <param name="headerText"></param>
- /// <param name="dataPropertyName"></param>
- 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);
- }
- }
- }
|