i have a column item-code, inside my database which i have bound to a datagrid view. The item-code comes in this format “A-B-C”, i wish only to show the “B” part of the code, i have bound this column to the gridview and now wish to make it show the substring. I tried defaultcellstyle.format but don’t know how to get a substring for it.
Share
Is it a possibility to add a new property to your bound object, something like ItemCodePart, which returns the middle part of your item-code, then bind this property to the column instead of item-code? That would be the simplest way.
Another option is to handle the CellFormatting event of the DataGridView and set e.Value to the part of item-code you want to show: