简体   繁体   English

删除Datagridview中的链接文本

[英]Remove link text in Datagridview

I have a DataGridView which is populated from a list. 我有一个从列表填充的DataGridView I then Have defined a link column in the last column which is not DataBound saying View , how do I remove this link text if a condition is met. 然后,我在最后一column中定义了一个链接column ,该column不是DataBound所说的View ,如果满足条件,如何删除此链接文本。 I have the below: 我有以下内容:

        dgvReport.AutoGenerateColumns = false;
        dgvReport.DataSource = queries;

        //locals 
        Int32 lastColumnIndex = this.dgvReport.Columns.Count - 1;

        //hide reads links for the null queries
        for (int i=0; i < queries.Count; i++) {
            if (queries[i].SomeID == null || queries[i].AnotherID == null) {
                this.dgvReport.Rows[i].Cells[lastColumnIndex].Value = "";
            }
        }

This is not working and my column text still shows View . 这不起作用,我的列文本仍然显示View Any ideas? 有任何想法吗?

Edit : lastColumnIndex is 24 which is indeed the last column index 编辑 :lastColumnIndex是24的确是最后一列索引

You might try 你可以试试

View.PlainTextBehaviour = true;

It will remove the link and show it as plain text 它将删除链接并将其显示为纯文本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM