数据表两行列 [英] Datatable two line columns
本文介绍了数据表两行列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我需要创建两行专栏。
喜欢这个。
第一栏:NAME COLUMN
jac Nicol
Mike Trol
第二栏:AGE生日
12 xxxxxx
20 xxxxxxx
表格将以网格显示。
hello
I need to create two line columns.
Like this.
first column: NAME COLUMN
jac Nicol
Mike Trol
Second column : AGE Birthday
12 xxxxxx
20 xxxxxxx
the table will be shown in grid like this.
推荐答案
好的,这是一个有点简单的任务,看看我的代码例如:
Okay that is a somewhat simple task, look at my code example:
DataTable datatable = new DataTable();
datatable.Columns.Add("Name",typeof(string));
datatable.Columns.Add("Age Birthday",typeof(string));
//Note here that I am making both columns string for simplicity.
datatable.Rows.Add("Name", "John Doe");
//Assuming you have a DateTime variable called birthday where the actual birthday is stored
datatable.Rows.Add("Age", (DateTime.Now.Year - birthday.Year).toString() + " " + birthday.toString("dd-MM-yyyy"));
我希望这有帮助,编码愉快!
I hope this helps, happy coding!
这篇关于数据表两行列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文