Luis Dangel

Luis Dangel

  • NA
  • 1
  • 10.3k

Display format in DatagridView Column

Aug 12 2010 4:26 PM

Hi guys. Can you please help me with the following?

Is there an easy way to change the displayed value of a Datagridview column? For example right now the column is displaying a string field like this "ZAF1234500", I need to show in the column the same string but separated by hyphens like this "ZA-F12345-00".

If possible, I want to do it without using the MaskedTextBox or without creating an extra concatenated column in the source DataTable, also the display with hyphens should be in all the visible rows and not only in the selected row.

Can this be done with the format property? Or

Do I really need to subclass the MaskedTextBox control to host it in the DataGridview?

The other solution I thought is to create an extra column in the DataTable with the substrings of the string and concatenate the hyphen, but that will implicates more work and if possible I want to avoid it since it's in several places.

Thanks a lot for your help


Answers (1)