{"id":78,"date":"2009-10-24T18:43:33","date_gmt":"2009-10-24T17:43:33","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=64"},"modified":"2009-10-24T18:43:33","modified_gmt":"2009-10-24T17:43:33","slug":"format-input-date-in-datagridview","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=78","title":{"rendered":"Format input date in datagridview"},"content":{"rendered":"<p>A common problem faced in datagridview is how to format the date in the grid, here is a small way to do it:<\/p>\n<blockquote><p>Private Sub dataGridView1_CellParsing(ByVal sender As Object, ByVal e As DataGridViewCellParsingEventArgs)<\/p>\n<p>If e.ColumnIndex = 0 Then<\/p>\n<p>Dim [date] As String = DirectCast(e.Value, String)<\/p>\n<p>Try<\/p>\n<p>Dim month As String = [date].Substring(0, 2)<\/p>\n<p>Dim day As String = [date].Substring(2, 2)<\/p>\n<p>Dim year As String = [date].Substring(4, 4)<\/p>\n<p>e.Value = New DateTime(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day))<\/p>\n<p>e.ParsingApplied = True<br \/>\nCatch ex As Exception<\/p>\n<p>MessageBox.Show(&#8220;parsing error!&#8221;)<\/p>\n<p>End Try<\/p>\n<p>End If<br \/>\nEnd Sub<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>A common problem faced in datagridview is how to format the date in the grid, here is a small way to do it: Private Sub dataGridView1_CellParsing(ByVal sender As Object, ByVal e As DataGridViewCellParsingEventArgs) If e.ColumnIndex = 0 Then Dim [date] As String = DirectCast(e.Value, String) Try Dim month As String = [date].Substring(0, 2) Dim day [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[110],"tags":[34,39,131],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/78"}],"collection":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78"}],"version-history":[{"count":0,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}