c# - Input string was not in a correct format -


i have piece of code:

private string gettime(int time) {     timespan t = timespan.fromseconds(time);     return string.format("{0:d2}:{1:d2}", t.hours, t.minutes, t.seconds, t.milliseconds); } 

and later on in application part of code:

datagridview_trips.rows[i].cells["top_tijd"].value = (string)gettime(routeinfo[0]); 

no matter how or try cast string, once tries set value of cells["top_tijd"] give me error that, in case, gettime returns string "17:46" , tells me not correct decimal format?

it's trying set strong tell me not correct decimal value, why?

edit1:

tried adding datagridview_trips.columns["top_tijd"].valuetype = typeof(string); no avail.

edit2:

tried remove gettime , pasted in hardcoded "test" , claims same wants decimal after setting it's valuetype.

edit3:

here's screenshot of format behavior... (no formatting.) enter image description here

i had same problem: i've solved changing value type in column of ms access database binded dgv's column.

you can't change type of binded column directly visual studio: if column has setted datapropertyname, it's name of db column you've change.

if can't edit db, must copy column's values new not-binded column.


Comments