I’m following this question for formatting timespan value in the gridview.
Format TimeSpan in DataGridView column
I’m diaplying only minutes value in grid as follows
DataGridViewColumn idleTimeColumn = myGridView.Columns["IdleTime"];
idleTimeColumn.DefaultCellStyle.FormatProvider = new TimeSpanFormatter();
idleTimeColumn.DefaultCellStyle.Format = "m";
This cell is editable, so when I enter 5 (that mean 5 min) in the cell, then it should take it minute, but it take it as day value (ie, 5.00:00:00).
I tried different values for format (mm,%m) but all these gives the same output.
You have to implement the feature to parse an input value.
TimeSpanFormatter can be used to convert a bound TimeSpan data to a formatted string for displaying. But it can’t convert an input value to TimeSpan. You have to convert an input value in DataGridView.CellParsing event handler.
The following is the sample code to parse an input value.
DataGridView.CellParsing event handler
TimeSpanParser class
TimeSpanPart enum