C# dev gridcontrol "time" string formatting
public void FormateDate(ref DataSet ds, string colName) { if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { string ColumnValue = Convert.ToString(dr[colName]); while (ColumnValue.IndexOf(".") > 0) { ColumnValue = ColumnValue.Replace(".", ""); } if (ColumnValue.Length >= 8) { dr[colName] = string.Concat(new string[] { ColumnValue.Substring(0, 4), ".", ColumnValue.Substring(4, 2), ".", ColumnValue.Substring(6, 2) }); } } } }
Function function:
Before binding the time to DEV gridcontrol, you can format 20090212 The formatted string is converted to the format of 2009.02.12 for easy use
Small Note:
String.Concat method: Connect one or more instances of String, or one or more instances of Object String representation of the value of multiple instances (if the argument is not of type string, it is first converted to a string using the string() function, and then the result of that conversion is evaluated). For specific explanation, see: Click to open the link
The above is the content of C# dev gridcontrol "time" string formatting. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!