如何在datagrid的acolum中显示系统日期和时间? [英] how to show system date and time in acolum of datagrid?

查看:120
本文介绍了如何在datagrid的acolum中显示系统日期和时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagrid.i想要添加一个新列,我想要系统时间,我该怎么办?



i可以显示值来自数据库的网格..现在我想在网格中添加一个新的列。网格应该包含系统时间

i having a datagrid.i want to add a new column and i wantsystem time in it,,how can i do that?

i could display values in the gird from database..now i want to add a new colum to the grid.the grid should contain system time

推荐答案

试试这个

try this
DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("NewColumnName", typeof(DateTime)));
            dt.Rows.Add(DateTime.Now);
            dataGridView1.DataSource = dt;


由于您需要在网格视图中显示当前系统时间,只需选择当前日期为getdate()并绑定我们对其他专栏做了这一栏。



快乐编码..
As you need to show the current system time in grid view just select current date as getdate() and bind this column as we do to other column.

happy coding ..


这篇关于如何在datagrid的acolum中显示系统日期和时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆