隐藏仅在所选行DataGridView中取消隐藏列 [英] Hide Unhide Columns Only in Selected Row DataGridView

查看:157
本文介绍了隐藏仅在所选行DataGridView中取消隐藏列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有三行编辑,删除,保存按钮。我已经隐藏了表单加载上的保存按钮。现在我想要隐藏取消隐藏保存按钮并在所选行中单击编辑按钮时隐藏编辑按钮。



我尝试使用列[columnIndex] .visible = false; < br $>


Hi All,
I Have three rows with edit, delete, save buttons. I have hided save button on form load. now i want to hide unhide save button and hide edit button on clicking edit button only in selected row.

I tried using columns[columnIndex].visible = false;

this.DataGridView1.Columns[0].Visible = false;
          this.DataGridView1.Columns[1].Visible = true;



但它隐藏了该索引的所有列。我只想更改选定的行列,而不更改其他列。


But it hides all columns with that index. I want only the selected rows column to be changed leaving other columns unchanged.

推荐答案

最简单的解决方案是设置 ReadOnly 属性为true。



另一种方法可能是使单元格样式透明。

The easiest solution would be to set the ReadOnly property to true.

Another approach could be to make the cell style transparent.
Style = { ForeColor = Color.Transparent,SelectionForeColor = Color.Transparent }


这篇关于隐藏仅在所选行DataGridView中取消隐藏列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆