merging two datagridview columns into one new column

后端 未结 2 1293
情深已故
情深已故 2021-01-14 07:36

i want to merge two datagridview columns into one new column.

i first change Visible property of two col to false, then i try to add new col which that value must be

2条回答
  •  自闭症患者
    2021-01-14 08:05

    Try this (it works for me):

    reportResultForm.dgvResult.Columns.Add("newColumn", "New Column");
            foreach (DataGridViewRow row in reportResultForm.dgvResult.Rows)
            {
                string height= row.Cells["Height"].Value.ToString();
                string width= row.Cells["Width"].Value.ToString();
                string formattedCol= string.Format("{0} per {1}", height, width);
                row.Cells["newColumn"].Value = formattedCol;
            }
    

提交回复
热议问题