C# 在 Infragistics UltraGrid 中启用和禁用列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11802054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 19:19:36  来源:igfitidea点击:

Enabling and disabling of columns in Infragistics UltraGrid

c#infragistics

提问by user1567194

I have an Infragistics grid and I want to disable and enable some columns based upon some requirement. I have read some articles that say to use AllowUpdate = DefaultableBoolean.Truebut it did not work for me.

我有一个 Infragistics 网格,我想根据某些要求禁用和启用某些列。我读过一些文章说要使用,AllowUpdate = DefaultableBoolean.True但它对我不起作用。

回答by Steve

I suppose that when you talk of disabled columns you mean disable editing in these columns. Also you don't specify the language, so I will use C#

我想当您谈到禁用的列时,您的意思是禁用这些列中的编辑。你也没有指定语言,所以我将使用 C#

UltraGridColumn c = grdWork.DisplayLayout.Bands[0].Columns["YourColumnName"];
c.CellActivation = Activation.NoEdit; 
c.CellClickAction = CellClickAction.CellSelect;

The property CellActivationcould also be set to Activation.Disabledor Activation.ActivateOnly.
The property CellClickActionallows to set an appropriate selection status for the cell clicked. You could use CellSelector RowSelect. (This last one, to mimic the behavior of a ListBox)
As usual, the real difficulty is to find the correct property. Then Intellisense will give you a quick and fair explanation of the meaning of these values.

属性CellActivation也可以设置为Activation.DisabledActivation.ActivateOnlyCellClickAction
属性允许为单击的单元格设置适当的选择状态。您可以使用或。(这最后一个,模仿 ListBox 的行为) 像往常一样,真正的困难是找到正确的属性。然后 Intellisense 会给你一个快速而公正的解释这些值的含义。CellSelectRowSelect

回答by Subba Rao

If you just want to show and hide the columns as needed then you can try the following.

如果您只想根据需要显示和隐藏列,则可以尝试以下操作。

UltraGrid myGrid = new UltraGrid();
//Bind to your data here
myGrid.DisplayLayout.Bands[0].Columns["ColumnName"].Hidden = true;