DataTable 与 datagrid控件
datagrid控件的作用简单点说就是将表格显示出来,用的多的是直接链接数据库文件,也可以自己见一个表格对象,链接到datagrid控件,下面是一个简单的例子
DataTable dt = new DataTable();
//新建列
DataColumn col1 = new DataColumn("设备名", typeof(string));
DataColumn col2 = new DataColumn("管理员", typeof(string));
DataColumn col3 = new DataColumn("设备ID", typeof(string));
DataColumn col4 = new DataColumn("所属权限", typeof(string));
DataColumn col5 = new DataColumn("状态", typeof(string));
DataColumn col6 = new DataColumn("购买时间", typeof(string));
DataColumn col7 = new DataColumn("最新维护时间", typeof(string));
DataColumn col8 = new DataColumn("设备管理员ID", typeof(string));
//添加列
dt.Columns.Add(col1);
dt.Columns.Add(col2);
dt.Columns.Add(col3);
dt.Columns.Add(col4);
dt.Columns.Add(col5);
dt.Columns.Add(col6);
dt.Columns.Add(col7);
dt.Columns.Add(col8);
//新建行
DataRow row1 = dt.NewRow();
//行赋值
row1["设备名"] = "打印机";
row1["管理员"] = "李居明";
row1["设备ID"] = "JFKSJFKSDFJK151";
row1["所属权限"] = "普通用户";
row1["状态"] = "在库";
row1["购买时间"] = "2012-03-20";
row1["最新维护时间"] = "2012-03-27";
row1["设备管理员ID"] = "无";
//添加行
dt.Rows.Add(row1);
//数据绑定
this.dataGrid1.DataSource = dt;
//设置属性
DataGridTableStyle tablestyle = new DataGridTableStyle();
this.dataGrid1.TableStyles.Add(tablestyle);
dataGrid1.TableStyles[0].GridColumnStyles[0].Width = 75;
dataGrid1.TableStyles[0].GridColumnStyles[1].Width = 75;
dataGrid1.TableStyles[0].GridColumnStyles[2].Width = 75;
dataGrid1.TableStyles[0].GridColumnStyles[3].Width = 75;
dataGrid1.TableStyles[0].GridColumnStyles[4].Width = 75;
dataGrid1.TableStyles[0].GridColumnStyles[5].Width = 120;
dataGrid1.TableStyles[0].GridColumnStyles[6].Width = 120;
dataGrid1.TableStyles[0].GridColumnStyles[6].Width = 120;
DataTable 与 datagrid控件相关推荐
- 使用c#+(datagrid控件)编辑xml文件
作者Blog:http://blog.csdn.net/ouyang76cn/ 使用c#+(datagrid控件)编辑xml文件 这个源码是我根据网上一个vb.net编辑xml文件的原理用c#重写的. ...
- 使用 ASP+ DataGrid 控件来创建主视图/详细资料视图
Nikhil Kothari Microsoft Corporation 2000年8月 简介 Microsoft® Visual Studio.NET 的下一发行版包括 DataGrid Web 控 ...
- C#中DataGrid控件的基本使用
datagrid控件的作用简单点说就是将表格显示出来,用的多的是直接链接数据库文件,也可以自己见一个表格对象,链接到datagrid控件,下面是一个简单的例子 1 //xinjiabiao 2 Dat ...
- WPF中如何将List<string>数据绑定到DataGrid控件中
一,前端 <DataGrid x:Name="Onlinedatagrid" AutoGenerateColumns="True" HorizontalA ...
- datagrid控件使用技巧大集合
引用自:http://www.cnblogs.com/iCeSnaker/archive/2004/07/31/29017.aspx 1.DataGrid的正反双向排序 http://dev.csdn ...
- DataGrid 控件使用技巧集合
datagrid控件使用技巧大集合 引用自:http://www.cnblogs.com/iCeSnaker/archive/2004/07/31/29017.aspx 1.DataGrid的正反双向 ...
- java datagrid控件_12款Javascript表格控件(DataGrid)
(图片与项目有出入) 表格控件(DataGrid )允许最终用户阅读和写入到绝大多数数据库的应用程序.DataGrid 控件可以在设计时快速进行配置,只需少量代码或无需代码.当在设计时设置了DataG ...
- asp.net中显示DataGrid控件列序号的几种方法
在aps.net中多数据绑定的控件很多,论功能来说,应该属DataGrid最为齐全,但它没有提供现成的显示记录序号的功能,不过我们可以通过它所带的一些参数来间接得到序号,下面来看看怎样得到和显示序号值 ...
- DataGrid控件读取具体某行某列的值、获取总列数
WPF中的datagrid控件获取总列数的函数是Items.Count来获取. 以下代码是循环获取各行第二列的数据,并存放在一个名为TX的Textbox控件中: for (int i = 0; i & ...
最新文章
- 熬夜翻译完的PureFTPd配置文件
- MySQL存储过程---动态的表名
- eclipse中启动tomcat出现错误的解决方法
- 华为的Java虚拟机_华为方舟编译器解析:提升安卓运行效率
- SAP Spartacus B2B页面Budget页面的设计原理
- 笨方法“学习python笔记之print换行
- MySQL 异常有这一篇就够了!
- mediarecoder 安卓_android 通过MediaRecorder实现简单的录音示例
- CodeProject 精彩系列
- node2vec的一些理解
- 高职高考计算机网课app,本人准备高职高考,但是初中数学基础不行,所以求一套不错的初中数学练习题,教材的话我就刷网课。...
- android switch背景图片,修改SwitchCompat的背景图片
- coffeescript html5,CoffeeScript函数
- Hacked by 1BYTE
- win11共享打印机无法连接怎么办
- Whole Word Masking
- 多出口路由及其动态切换的配置
- Blueprint介绍和使用
- java andequal_Java equals 和 == 完全解析
- input type=number 禁止输入E
热门文章
- 可视化HTA窗体设计器-HtaMaker 界面介绍及使用方法,下载 | HTA VBS可视化脚本编写
- SiO2 酰肼修饰单分散二氧化硅微球/胺基修饰二氧化硅改性环氧树脂胶粘剂/硅烷修饰二氧化硅微球/3-氨丙基三乙氧基硅烷(APTS)修饰的二氧化硅
- MT6771/Helio P60芯片处理器资料介绍
- 创建linux用户(修改组、umask、密码)
- Power Pivot(了解power pivot,获取数据,计算字段(度量值)和计算列,按列排序,多表模型关系创建)
- 补偿 100 万? Oracle 裁员 900 人!
- android p音量插件,安卓p音量条v1.9.2
- 随机森林算法初步实现
- Java技术——驰骋编程世界的利器
- 梦幻西游三维获取服务器信息,梦幻西游三维版:潜能果上线后经验紧缺?五分钟教你快速获得经验...