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 formatted as this which col1Value and col2Value is value of above columns:
string.Format("{0} per {1}", col1Value, col2Value);
my code
reportResultForm.dgvResult.Columns["Height"].Visible = false;
reportResultForm.dgvResult.Columns["Width"].Visible = false;
DataGridViewColumn col = new DataGridViewColumn();
col.DefaultCellStyle.Format = "{0} per {1}";
col.CellTemplate = new DataGridViewTextBoxCell();
dgvResult.Columns.Add(col);
but i dont know how do this! please help me. my way is true?
You can made your own implementation of the DataGridViewTextBoxCell and override GetFormattedValue method for it. There you can return the formatted value for your column below is an example:
…
hope this helps, regards