listview控件使用

这篇博客介绍如何利用ListView控件展示待更新的数据库DDL和DML文件,内容涉及数据绑定及异常处理。
摘要由CSDN通过智能技术生成

 本文是用listview显示需要更新的数据库文件,一些ddl和dml文件。

其中用到了listview的绑定。


private void AddDateTableRow(DataTable table, string title, string msg)

        {
            DataRow row = table.NewRow();
            row["标题"] = title;
            row["执行信息"] = msg;
            table.Rows.Add(row);
            this.dataGridView1.DataSource = table;
            this.dataGridView1.Refresh();
        }
        protected override void OnLoad(EventArgs e)
         
        {
            string currentddl="";
            string currentdml="";
            string lasteddl="";
            string lastedml="";
            currentddl = ServerGlobal.dict["CURRENTDDLVER"].ToString();
            currentdml = ServerGlobal.dict["CURRENTDMLVER"].ToString();
            lasteddl = ServerGlobal.dbDict["LastestDDLVer"].ToString();
            lastedml = ServerGlobal.dbDict["LastestDMLVer"].ToString();
            base.OnLoad(e);
            CreateViewItemMethodTow();
            this.textBox1.Text = currentddl;
            this.textBox2.Text = lasteddl;
            this.textBox3.Text = currentdml;
            this.textBox4.Text = lastedml;
            this.button2.Enabled = false;
 
        }
       
//加载listview
        public void CreateViewItemMethodTow()
        {
            this.listView1.View = View.Details;
            this.listView1.BeginUpdate();
            this.listView1.Columns.Add("文件名");
            this.listView1.Columns.Add("大小");
            this.listView1.Columns.Add("創建日期");

            path = Application.StartupPath + @"\DBUpdate";
            DirectoryInfo dir = new DirectoryInfo(path);
            DirectoryInfo[] dirs = dir.GetDirectories();

            FileInfo[] finfo = dir.GetFiles("*.ddlsql");
            FileInfo[] finfo1 = dir.GetFiles("*.dmlsql");
            ListViewItem lviItem;
            ListViewItem.ListViewSubItem lviSubItem;

            foreach (DirectoryInfo di in dirs)
            {
 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值