博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DataGridView数据控件演示
阅读量:6969 次
发布时间:2019-06-27

本文共 1523 字,大约阅读时间需要 5 分钟。

书上的一段话,没有深入介绍呀。这才是我感兴趣的。

。。。基要以小型网格显示只读值或者使用户能够编辑具有数百万条记录的表,DataGridView控件将提供可以方便地进行编程以及有效地利用内存的解决方案。。。。。。

BUT,后来书上都没有讲的。。

复制代码
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms;10 using System.Data.SqlClient;11 12 namespace WindowsFormsApplication713 {14     public partial class Form1 : Form15     {16         SqlConnection conn;17         SqlDataAdapter sda;18         DataSet ds = null;19         public Form1()20         {21             InitializeComponent();22         }23 24         private void Form1_Load(object sender, EventArgs e)25         {26             conn = new SqlConnection("server = .; database = msdb ; uid = A; pwd = B");27             sda = new SqlDataAdapter("select * from MSdbms_map", conn);28             ds = new DataSet();29             sda.Fill(ds, "map");30             dataGridView1.DataSource = ds.Tables[0];31             dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;32             dataGridView1.ReadOnly = true;33             dataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkRed;34         }35 36         private void button1_Click(object sender, EventArgs e)37         {38             string msg = string.Format("第{0}行,第{1}列", dataGridView1.CurrentCell.RowIndex, dataGridView1.CurrentCell.ColumnIndex);39             label1.Text = "选择的单元格为: " + msg;40         }41     }42 }
复制代码

转载地址:http://xbpsl.baihongyu.com/

你可能感兴趣的文章
Nginx的连接处理方法
查看>>
22个开源的PHP框架
查看>>
进桌面点右键就提示内存不能读,再点确定后就自动注销。
查看>>
New Features in Xcode 6
查看>>
反射应用和集合按照某个字段排序
查看>>
NFS基于linux用户和UINX用户的文件共享
查看>>
Perl UTF-8字符开关
查看>>
JAVASE 增强
查看>>
iptables常用选项及应用实例操作
查看>>
SharePoint开发部署WSP解决方案包
查看>>
redis之strings类型及操作
查看>>
C段查询雏形之在Java中反查一个IP上的所有域名(旁站查询)
查看>>
关于NetApp: Data Ontap 7 mode 和cluster mode
查看>>
升级 SQL Server 故障转移群集的限制
查看>>
Intellij idea maven web项目创建过程
查看>>
Server系列14:密码遗忘之后:非常规登录win2012服务器事件记录
查看>>
【CentOS】grant root authority to normal user
查看>>
我的友情链接
查看>>
webbench功能测试
查看>>
WordPress不让上传.rar格式附件的原因及解决办法
查看>>