zoukankan      html  css  js  c++  java
  • winform datagridview 列链接操作

    1.图片链接列
    
    DataGridViewImageColumn column = new DataGridViewImageColumn();
    
    dataGridView1.Columns.Add(column);
    
    column.Name= "btnopenproject";
    column.HeaderText = "操作";
    column.Image = Properties.Resources.open;
    
    //System.Drawing.Image.FromFile("C:\Users\DELL\Desktop\UserControls\Resources\open.png");
    
    //打开文件所在文件夹操作
            private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
            {
                if (dataGridView1.Columns[e.ColumnIndex].Name == "btnopenproject" && e.RowIndex >= 0)
                {
                    DataGridViewColumn column = dataGridView1.Columns[e.ColumnIndex];
                    int row = this.dataGridView1.CurrentRow.Index;
                    string projectPath = FileSystemAccess.GetPath(dataGridView1.Rows[row].Cells["项目名称"].Value.ToString());
                    System.Diagnostics.Process.Start(projectPath);
                }
            }
    
    2.文字链接列
    
     DataGridViewLinkColumn column = new DataGridViewImageColumn();
    
    dataGridView1.Columns.Add(column );
    
    column .Name = "btnopenproject";
    column .HeaderText = "操作";
    column .DefaultCellStyle.NullValue = "打开文件";
    
    3.按钮链接列
     DataGridViewButtonColumn column = new DataGridViewButtonColumn();
    
    dataGridView1.Columns.Add(column );
    
    column .Name = "btnopenproject";
    column .HeaderText = "操作";
    column .DefaultCellStyle.NullValue = "打开文件";
    

      

  • 相关阅读:
    细数ASP.NET MVC框架的7大顶级功能
    Ubuntu 10.10更新源列表
    使用iTunes将任意mp3文件转为iPhone铃声
    简单5步,在新浪微博上关联多个博客
    在windows 7 建立一个弹出光驱的快捷方式
    中国人民太伟大了!
    Ubuntu 10.10
    du 熊填数字
    WPF学习02——XAML编译
    Debugging WPF data bindings
  • 原文地址:https://www.cnblogs.com/yanranziruo/p/10648726.html
Copyright © 2011-2022 走看看