【问题标题】:How to add DataGridViewLinkColumn property to dynamically generated columns in DataGridView?如何将 DataGridViewLinkColumn 属性添加到 DataGridView 中动态生成的列?
【发布时间】:2011-06-10 03:50:15
【问题描述】:

开发中: c# winforms 没有任何数据库连接

说明: 在我的 DataGridView 中,列是动态生成的。在某些时候,某些列需要 DataGridViewLinkColumn 属性。我尝试了很多方法,但都没有做到这一点。

我希望这里的人能帮助我:)

提前致谢。

【问题讨论】:

    标签: c# winforms datagridview


    【解决方案1】:

    试试这个:

           DataGridViewLinkColumn links = new DataGridViewLinkColumn();
    
            links.HeaderText = "Hello";
            links.UseColumnTextForLinkValue = true;
            links.Text="http://microsoft.com";
            links.ActiveLinkColor = Color.White;
            links.LinkBehavior = LinkBehavior.SystemDefault;
            links.LinkColor = Color.Blue;
            links.TrackVisitedState = true;
            links.VisitedLinkColor = Color.YellowGreen;
    
            dataGridView.Columns.Add(links);
    

    【讨论】:

      【解决方案2】:

      您需要关闭AutoGenerateColumns,然后自己生成每一列。

      将普通列设置为DataGridViewTextBoxColumn 类型,然后对于需要链接的列将它们设置为DataGridViewLinkColumn 类型。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-01
        • 2012-04-09
        相关资源
        最近更新 更多