I have finally solved this. Based on some checking with the debugger and playing around with the code, I deducted the following: The default ValueType for the contents of each cell in a DatagridView is "String". In order for a numerical format to become effective, the ValueType needs to be "Decimal". The following code worked (Dgvx1 is my instance of the DataGridView):
For counter = 0 To Dgvx1.SelectedCells.Count - 1
With Dgvx1.SelectedCells(counter)
.ValueType = GetType(Decimal)
.Style.Format = "C2"
.Value =
CSng(.Value)
End With
Next
Note that the conversion of the original cell content (string) needs to converted to a numerical value in order for this to work. Without this, the format takes only effect when a new value is entered into the cell.
I am unsure whether this is the best way to handle this, but it works. I could not find anything anywhere in the documentation that was helping for a simple thing like this.