Let DataGird display after extracting data modification from the database

xiaoxiao2021-03-06  112

One column in DataGrid is a display date, but the designer inserts a continuous string in the database, now requires the format of 2004/08/03 23:16:16 in DataGIRD, there are several ideas: Modify in the data set, then write back the dataset, the other is to write a SQL statement, then directly modify the data set, then write the data set, and finally use a simpler method to directly modify the output of DataGIRD. Write a function:

Private Function Formator (Byval Strin As String) AS String Dim Strrtn As String = "" Strrtn = Left (Strin, 4) & "/" Strrtn = MID (Strin, 5, 2) & "/" Strrtn = MID ( Strin, 7, 2) & "Strrtn = MID (STRIN, 9, 2) &": "Strrtn = MID (Strin, 11, 2) &": "Strrtn = MID (Strin, 13, 2) Return Strrtn End Function

Finally insert this function in DataBing ()

For i = 0 to me.datagrid1.items.count - 1 DataGrid1.items (i) .cells (1) .text = formatdate (DataGrid1.Items (i) .Cells (1) .text) Next

转载请注明原文地址:https://www.9cbs.com/read-126526.html

New Post(0)